File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ b.bundle();
49
49
50
50
- ` rootDir ` : absolute path to your project's root directory. This is optional but providing it will result in better generated classnames.
51
51
- ` output ` : path to write the generated css
52
+ - ` json ` : path to write a json manifest of classnames
52
53
- ` use ` : optional array of postcss plugins (by default we use the css-modules core plugins)
53
54
54
55
## PostCSS Plugins
Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ module.exports = function (browserify, options) {
29
29
throw new Error ( 'css-modulesify needs the --output / -o option (path to output css file)' ) ;
30
30
}
31
31
32
+ var jsonOutFilename = options . json ;
33
+
32
34
// PostCSS plugins passed to FileSystemLoader
33
35
var plugins = options . use || options . u ;
34
36
if ( ! plugins ) {
@@ -128,6 +130,15 @@ module.exports = function (browserify, options) {
128
130
fs . writeFile ( cssOutFilename , css , function ( ) {
129
131
if ( typeof cb === 'function' ) cb . apply ( null , args ) ;
130
132
} ) ;
133
+
134
+ // write the classname manifest
135
+ if ( jsonOutFilename ) {
136
+ fs . writeFile ( jsonOutFilename , JSON . stringify ( tokensByFile ) , function ( err ) {
137
+ if ( err ) {
138
+ browserify . emit ( 'error' , err ) ;
139
+ }
140
+ } ) ;
141
+ }
131
142
} ) ;
132
143
133
144
return stream ;
You can’t perform that action at this time.
0 commit comments