Skip to content

Add css file extension option. #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ b.on('css stream', function (css) {
- `after`: optional array of postcss plugins to run after the required css-modules core plugins are run.
- `generateScopedName`: (API only) a function to override the default behaviour of creating locally scoped classnames.
- `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).
- `filePattern`: optional regular expression string to specify css file names. (default: `\.css$`)

### Events
- `b.on('css stream', callback)` The callback is called with a readable stream containing the compiled CSS. You can write this to a file.
Expand Down
4 changes: 2 additions & 2 deletions cmify.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ function Cmify(filename, opts) {

stream.Transform.call(this);

this.cssExt = /\.css$/;
this.cssFilePattern = new RegExp(opts.cssFilePattern || '\.css$');
this._data = "";
this._filename = filename;
this._cssOutFilename = opts.cssOutFilename;
}

Cmify.prototype.isCssFile = function (filename) {
return this.cssExt.test(filename)
return this.cssFilePattern.test(filename)
}

Cmify.prototype._transform = function (buf, enc, callback) {
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ module.exports = function (browserify, options) {
var cssOutFilename = options.output || options.o;
var jsonOutFilename = options.json || options.jsonOutput;
transformOpts.cssOutFilename = cssOutFilename;
transformOpts.cssFilePattern = options.filePattern;

// PostCSS plugins passed to FileSystemLoader
var plugins = options.use || options.u;
Expand Down