Skip to content

Commit

Permalink
Merge postcss-modules config (#75)
Browse files Browse the repository at this point in the history
* Merge postcss-modules config

* Use pure js instead of lodash

* formatting
  • Loading branch information
isbasex authored and devongovett committed Dec 8, 2017
1 parent c27c5c8 commit 582f8db
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/transforms/postcss.js
Expand Up @@ -24,12 +24,20 @@ async function getConfig(asset) {
}

config = config || {};

let postcssModulesConfig = {
getJSON: (filename, json) => (asset.cssModules = json)
};

if (config.plugins && config.plugins['postcss-modules']) {
postcssModulesConfig = Object.assign(config.plugins['postcss-modules'], postcssModulesConfig);
delete config.plugins['postcss-modules'];
}

config.plugins = loadPlugins(config.plugins, asset.name);

if (config.modules) {
config.plugins.push(localRequire('postcss-modules', asset.name)({
getJSON: (filename, json) => asset.cssModules = json
}));
config.plugins.push(localRequire('postcss-modules', asset.name)(postcssModulesConfig));
}

if (asset.options.minify) {
Expand Down

0 comments on commit 582f8db

Please sign in to comment.