File tree 4 files changed +16
-11
lines changed 4 files changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -146,6 +146,7 @@ You have two way to escape the transform
146
146
{
147
147
" mapName" : " makeLocal" ,
148
148
" tag" : " MYTAG" ,
149
+ " format" : " less" ,
149
150
" names" : {" cssobj" : {" name" : " _cssobj" , " path" : " ./cssobj" }}
150
151
} ] ]
151
152
}
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ module.exports = function (babel) {
31
31
var option = state . opts // babel5: state===opts
32
32
option = objutil . defaults ( option , {
33
33
tag : 'CSSOBJ' ,
34
+ format : 'scss' ,
34
35
names : {
35
36
cssobj : { name : 'cssobj' , path : 'cssobj' }
36
37
}
@@ -79,7 +80,7 @@ module.exports = function (babel) {
79
80
}
80
81
81
82
// css object transform
82
- var obj = converter ( texts . join ( templateDelimiter ) )
83
+ var obj = converter ( texts . join ( templateDelimiter ) , option . format )
83
84
var objStr = util . inspect ( obj , { depth : null } )
84
85
. split ( '\'' + templateDelimiter + '\'' )
85
86
. map ( function ( v , i , arr ) {
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " babel-plugin-transform-cssobj" ,
3
- "version" : " 3.0.1 " ,
3
+ "version" : " 3.0.2 " ,
4
4
"description" : " Babel plugin to transform css into cssobj (CSS in JS engine), map class names into cssobj localized names" ,
5
5
"main" : " index.js" ,
6
6
"directories" : {
7
7
"test" : " test"
8
8
},
9
9
"files" : [
10
- " * .js" ,
11
- " *.md "
10
+ " index .js" ,
11
+ " transform-plugins.js "
12
12
],
13
13
"scripts" : {
14
14
"objutil" : " rollup -c ./node_modules/objutil/rollup.config.js --api defaults" ,
47
47
"dependencies" : {
48
48
"babel-plugin-syntax-jsx" : " ^6.18.0" ,
49
49
"cssobj-converter" : " *" ,
50
+ "js-yaml" : " *" ,
50
51
"objutil" : " ^2.0.7"
51
52
}
52
53
}
Original file line number Diff line number Diff line change @@ -117,19 +117,21 @@ cssobj({}, {
117
117
it ( 'should work with no config' , function ( ) {
118
118
let node = `
119
119
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
+ }
122
124
\`
123
125
`
124
126
expect ( lib ( node ) ) . to . equal ( `import cssobj from "cssobj";
125
127
126
128
var d = cssobj({
127
129
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
+ }
133
135
}
134
136
}, {});` )
135
137
You can’t perform that action at this time.
0 commit comments