-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
BUG: postcss module generates wrong hashes #972
Comments
Same here, this is a stopper for us, we cannot run our project which uses css modules at all. |
Second this {
"modules": true,
"plugins": {
"autoprefixer": {
"grid": true
},
"postcss-modules": {
"generateScopedName": "[name]__[local]___[hash:base64:3]"
}
}
} My generateScopedName never gets applied for some reason :( |
@iocat @laurib @kidandcat May have found something... ///!!! Just saw #2865 I could not get my package.json to work, specifficaly, the "babel": {
"presets": [
"@babel/preset-env"
],
"plugins": [
"@babel/plugin-proposal-class-properties",
[
"@babel/plugin-transform-react-jsx",
{
"pragmaFrag": "React.Fragment"
}
],
[
"react-css-modules",
{
"generateScopedName": "[path]__[name]__[local]__",
"handleMissingStyleName": "warn"
}
]
]
},
"postcss": {
"modules": true,
"plugins": {
"postcss-modules": {
"generateScopedName": "[path]__[name]__[local]__",
"globalModulePaths": [
".global."
],
"root": "."
},
"autoprefixer": {
"grid": true
}
}
} .... until I modified /src/transforms/postcss.js : SWITCHED LINES 55 / 56 File: node_modules\parcel-bundler\src\transforms\postcss.js
45:
46: let postcssModulesConfig = {
47: getJSON: (filename, json) => (asset.cssModules = json),
48: Loader: createLoader(asset),
49: generateScopedName: (name, filename) =>
50: `_${name}_${md5(filename).substr(0, 5)}`
51: };
52:
53: if (config.plugins && config.plugins['postcss-modules']) {
54: postcssModulesConfig = Object.assign(
55: postcssModulesConfig,
56: config.plugins['postcss-modules']
57: );
58: delete config.plugins['postcss-modules'];
59: } The original order of line 55 / 56 prevent anyone from overriding |
Bump @devongovett the PR is already created |
Any chance we can get this fix into the current v1.x branch? |
Fix parcel-bundler#972 (cherry picked from commit 5993813)
This a 🐛 bug report
🎛 Configuration (.babelrc, package.json, cli command)
postcss.config.js
package.json
.babelrc
🤔 Expected Behavior
Classnames in generated .css file should have hash which is 4 chars long and :global classname should not contain hash
😯 Current Behavior
Seems working correctly after restarting parcel.
Example:
.page-header {}
is converted to.page-header__1x8y {}
and:global .app-root
is converted to.app-root {}
Classnames are generated incorrectly after changing and saving css file
.page-header {}
is converted to._page-header__1x8y_1dxnl_1 {}
and:global .app-root
is converted to._app-root_1dxnl_12
When saving again then classnames are converted as shown below
.page-header {}
->._page-header__1x8y_15rqa_1 {}
:global .app-root
->._app-root_15rqa_12
💁 Possible Solution
🔦 Context
This is blocker bug.
💻 Code Sample
🌍 Your Environment
The text was updated successfully, but these errors were encountered: