Skip to content

Commit 8b5c4fa

Browse files
committed
add: js-yaml, option.format using scss
1 parent 63223f7 commit 8b5c4fa

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ You have two way to escape the transform
146146
{
147147
"mapName": "makeLocal",
148148
"tag": "MYTAG",
149+
"format": "less",
149150
"names": {"cssobj": {"name": "_cssobj", "path": "./cssobj"}}
150151
} ] ]
151152
}

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ module.exports = function (babel) {
3131
var option = state.opts // babel5: state===opts
3232
option = objutil.defaults(option, {
3333
tag: 'CSSOBJ',
34+
format: 'scss',
3435
names: {
3536
cssobj: {name: 'cssobj', path: 'cssobj'}
3637
}
@@ -79,7 +80,7 @@ module.exports = function (babel) {
7980
}
8081

8182
// css object transform
82-
var obj = converter(texts.join(templateDelimiter))
83+
var obj = converter(texts.join(templateDelimiter), option.format)
8384
var objStr = util.inspect(obj, {depth: null})
8485
.split('\'' + templateDelimiter + '\'')
8586
.map(function (v, i, arr) {

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"name": "babel-plugin-transform-cssobj",
3-
"version": "3.0.1",
3+
"version": "3.0.2",
44
"description": "Babel plugin to transform css into cssobj (CSS in JS engine), map class names into cssobj localized names",
55
"main": "index.js",
66
"directories": {
77
"test": "test"
88
},
99
"files": [
10-
"*.js",
11-
"*.md"
10+
"index.js",
11+
"transform-plugins.js"
1212
],
1313
"scripts": {
1414
"objutil": "rollup -c ./node_modules/objutil/rollup.config.js --api defaults",
@@ -47,6 +47,7 @@
4747
"dependencies": {
4848
"babel-plugin-syntax-jsx": "^6.18.0",
4949
"cssobj-converter": "*",
50+
"js-yaml": "*",
5051
"objutil": "^2.0.7"
5152
}
5253
}

test/test.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,19 +117,21 @@ cssobj({}, {
117117
it('should work with no config', function() {
118118
let node = `
119119
var d = CSSOBJ\`
120-
body { color: $\{getColor()\}; }
121-
.p1 { color: blue; font-size: 12px; }
120+
body {
121+
color: $\{getColor()\};
122+
.p1 { color: blue; font-size: 12px; }
123+
}
122124
\`
123125
`
124126
expect(lib(node)).to.equal(`import cssobj from "cssobj";
125127
126128
var d = cssobj({
127129
body: {
128-
color: getColor()
129-
},
130-
'.p1': {
131-
color: 'blue',
132-
fontSize: '12px'
130+
color: getColor(),
131+
'.p1': {
132+
color: 'blue',
133+
fontSize: '12px'
134+
}
133135
}
134136
}, {});`)
135137

0 commit comments

Comments
 (0)