Skip to content

Commit 3cc6dc6

Browse files
committed
added --after cli option (CLI counterpart to options.postcssAfter)
1 parent 2feeda9 commit 3cc6dc6

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

index.js

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,34 +37,36 @@ module.exports = function (browserify, options) {
3737
if (typeof plugins === 'string') {
3838
plugins = [ plugins ];
3939
}
40+
}
4041

41-
plugins = plugins.map(function requirePlugin (name) {
42-
// assume functions are already required plugins
43-
if (typeof name === 'function') {
44-
return name;
45-
}
42+
var postcssAfter = options.postcssAfter || options.after || [];
43+
plugins = plugins.concat(postcssAfter);
4644

47-
var plugin = require(require.resolve(name));
45+
// load plugins by name (if a string is used)
46+
plugins = plugins.map(function requirePlugin (name) {
47+
// assume functions are already required plugins
48+
if (typeof name === 'function') {
49+
return name;
50+
}
4851

49-
// custom scoped name generation
50-
if (name === 'postcss-modules-scope') {
51-
options[name] = options[name] || {};
52-
if (!options[name].generateScopedName) {
53-
options[name].generateScopedName = createScopedNameFunc(plugin);
54-
}
55-
}
52+
var plugin = require(require.resolve(name));
5653

57-
if (name in options) {
58-
plugin = plugin(options[name]);
59-
} else {
60-
plugin = plugin.postcss || plugin();
54+
// custom scoped name generation
55+
if (name === 'postcss-modules-scope') {
56+
options[name] = options[name] || {};
57+
if (!options[name].generateScopedName) {
58+
options[name].generateScopedName = createScopedNameFunc(plugin);
6159
}
60+
}
6261

63-
return plugin;
64-
});
65-
}
62+
if (name in options) {
63+
plugin = plugin(options[name]);
64+
} else {
65+
plugin = plugin.postcss || plugin();
66+
}
6667

67-
plugins = plugins.concat(options.postcssAfter || []);
68+
return plugin;
69+
});
6870

6971
// keep track of css files visited
7072
var filenames = [];

0 commit comments

Comments
 (0)