Skip to content

Commit 482ba08

Browse files
committed
Add css file extension option.
1 parent 729552b commit 482ba08

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ b.on('css stream', function (css) {
7171
- `after`: optional array of postcss plugins to run after the required css-modules core plugins are run.
7272
- `generateScopedName`: (API only) a function to override the default behaviour of creating locally scoped classnames.
7373
- `global`: optional boolean. Set to `true` if you want `css-modulesify` to apply to `node_modules` as well as local files. You can read more about it in the [browserify docs](https://github.com/substack/node-browserify/#btransformtr-opts).
74+
- `filePattern`: optional regular expression string to specify css file names. (default: `\.css$`)
7475

7576
### Events
7677
- `b.on('css stream', callback)` The callback is called with a readable stream containing the compiled CSS. You can write this to a file.

cmify.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ function Cmify(filename, opts) {
1010

1111
stream.Transform.call(this);
1212

13-
this.cssExt = /\.css$/;
13+
this.cssFilePattern = new RegExp(opts.cssFilePattern || '\.css$');
1414
this._data = "";
1515
this._filename = filename;
1616
this._cssOutFilename = opts.cssOutFilename;
1717
}
1818

1919
Cmify.prototype.isCssFile = function (filename) {
20-
return this.cssExt.test(filename)
20+
return this.cssFilePattern.test(filename)
2121
}
2222

2323
Cmify.prototype._transform = function (buf, enc, callback) {

index.js

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ module.exports = function (browserify, options) {
101101
var cssOutFilename = options.output || options.o;
102102
var jsonOutFilename = options.json || options.jsonOutput;
103103
transformOpts.cssOutFilename = cssOutFilename;
104+
transformOpts.cssFilePattern = options.filePattern;
104105

105106
// PostCSS plugins passed to FileSystemLoader
106107
var plugins = options.use || options.u;

0 commit comments

Comments
 (0)