Skip to content

Commit eb54d58

Browse files
committed
generate a manifest json of export tokens
1 parent c19c613 commit eb54d58

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ b.bundle();
4949

5050
- `rootDir`: absolute path to your project's root directory. This is optional but providing it will result in better generated classnames.
5151
- `output`: path to write the generated css
52+
- `json`: path to write a json manifest of classnames
5253
- `use`: optional array of postcss plugins (by default we use the css-modules core plugins)
5354

5455
## PostCSS Plugins

index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ module.exports = function (browserify, options) {
2929
throw new Error('css-modulesify needs the --output / -o option (path to output css file)');
3030
}
3131

32+
var jsonOutFilename = options.json;
33+
3234
// PostCSS plugins passed to FileSystemLoader
3335
var plugins = options.use || options.u;
3436
if (!plugins) {
@@ -128,6 +130,15 @@ module.exports = function (browserify, options) {
128130
fs.writeFile(cssOutFilename, css, function () {
129131
if (typeof cb === 'function') cb.apply(null, args);
130132
});
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+
}
131142
});
132143

133144
return stream;

0 commit comments

Comments
 (0)