-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds stylus & less preprocessor (#5)
* test: style preprocess * fix: postcss is undefined issue by using import syntax * feat: adds less preprocessor * feat: adds stylus preprocessor * chore: remove unnecessary dir in test script * chore: add circleci config
- Loading branch information
Showing
9 changed files
with
671 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Javascript Node CircleCI 2.0 configuration file | ||
# | ||
# Check https://circleci.com/docs/2.0/language-javascript/ for more details | ||
# | ||
version: 2 | ||
jobs: | ||
build: | ||
docker: | ||
- image: circleci/node:6 | ||
|
||
working_directory: ~/repo | ||
|
||
steps: | ||
- checkout | ||
|
||
# Download and cache dependencies | ||
- restore_cache: | ||
keys: | ||
- v1-dependencies-{{ checksum "package.json" }} | ||
# fallback to using the latest cache if no exact match is found | ||
- v1-dependencies- | ||
|
||
- run: yarn install | ||
|
||
- save_cache: | ||
paths: | ||
- node_modules | ||
key: v1-dependencies-{{ checksum "package.json" }} | ||
|
||
# run tests! | ||
- run: yarn test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { parse } from '../lib/parse' | ||
import { compileStyle } from '../lib/compileStyle' | ||
|
||
test('preprocess less', () => { | ||
const style = parse({ | ||
source: | ||
'<style lang="less">\n' + | ||
'@red: rgb(255, 0, 0);\n' + | ||
'.color { color: @red; }\n' + | ||
'</style>\n', | ||
filename: 'example.vue', | ||
needMap: true | ||
}).styles[0] | ||
const result = compileStyle({ | ||
id: 'v-scope-xxx', | ||
filename: 'example.vue', | ||
source: style.content, | ||
map: style.map, | ||
scoped: false, | ||
preprocessLang: style.lang | ||
}) | ||
|
||
expect(result.errors.length).toBe(0) | ||
expect(result.code).toEqual(expect.stringContaining('color: #ff0000;')) | ||
expect(result.map).toBeTruthy() | ||
}) | ||
|
||
test('preprocess scss', () => { | ||
const style = parse({ | ||
source: | ||
'<style lang="scss">\n' + | ||
'$red: rgb(255, 0, 0);\n' + | ||
'.color { color: $red; }\n' + | ||
'</style>\n', | ||
filename: 'example.vue', | ||
needMap: true | ||
}).styles[0] | ||
const result = compileStyle({ | ||
id: 'v-scope-xxx', | ||
filename: 'example.vue', | ||
source: style.content, | ||
map: style.map, | ||
scoped: false, | ||
preprocessLang: style.lang | ||
}) | ||
|
||
expect(result.errors.length).toBe(0) | ||
expect(result.code).toEqual(expect.stringContaining('color: red;')) | ||
expect(result.map).toBeTruthy() | ||
}) | ||
|
||
test('preprocess sass', () => { | ||
const style = parse({ | ||
source: | ||
'<style lang="sass">\n' + | ||
'$red: rgb(255, 0, 0);\n' + | ||
'.color\n' + | ||
' color: $red\n' + | ||
'</style>\n', | ||
filename: 'example.vue', | ||
needMap: true | ||
}).styles[0] | ||
const result = compileStyle({ | ||
id: 'v-scope-xxx', | ||
filename: 'example.vue', | ||
source: style.content, | ||
map: style.map, | ||
scoped: false, | ||
preprocessLang: style.lang | ||
}) | ||
|
||
expect(result.errors.length).toBe(0) | ||
expect(result.code).toEqual(expect.stringContaining('color: red;')) | ||
expect(result.map).toBeTruthy() | ||
}) | ||
|
||
test('preprocess stylus', () => { | ||
const style = parse({ | ||
source: | ||
'<style lang="styl">\n' + | ||
'red-color = rgb(255, 0, 0);\n' + | ||
'.color\n' + | ||
' color: red-color\n' + | ||
'</style>\n', | ||
filename: 'example.vue', | ||
needMap: true | ||
}).styles[0] | ||
const result = compileStyle({ | ||
id: 'v-scope-xxx', | ||
filename: 'example.vue', | ||
source: style.content, | ||
map: style.map, | ||
scoped: false, | ||
preprocessLang: style.lang | ||
}) | ||
|
||
expect(result.errors.length).toBe(0) | ||
expect(result.code).toEqual(expect.stringContaining('color: #f00;')) | ||
expect(result.map).toBeTruthy() | ||
}) |
Oops, something went wrong.