Skip to content
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

CSS Modules generateScopedName override #2865

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions packages/core/parcel-bundler/src/transforms/postcss.js
Expand Up @@ -44,20 +44,23 @@ async function getConfig(asset) {
}

let postcssModulesConfig = {
getJSON: (filename, json) => (asset.cssModules = json),
Loader: createLoader(asset),
generateScopedName: (name, filename) =>
`_${name}_${md5(filename).substr(0, 5)}`
};

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

Object.assign(postcssModulesConfig, {
getJSON: (filename, json) => (asset.cssModules = json),
Loader: createLoader(asset)
})

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

if (config.modules || enableModules) {
Expand Down