You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature] add CSS Modules (postcss-modules) support #227
@felixsanz Are you using LoaderOptionsPlugin in your webpack.config.js? Normally it shouldn't affect the CSS Modules implementation of css-loader, but this was claimed a few times now. #232#222
You can't really use the postcss-modules plugin with webpack. It purpose is for other build tools like gulp/grunt. CSS Modules are handled by css-loader which is responsible for exporting the locals correctly
importstylesfrom'./file.css'// <= only works with 'css-loader' atmexportdefault(props)=>(<divclassName={styles.container}></div>)
import'./file.css'importstylesfrom'./modules.json'// <= `postcss-modules` (Crap, don't use it)exportdefault(props)=>(<divclassName={styles.container}></div>)
Also remove your custom HMR Code from the component,style-loader adds the necessary HMR Code automatically. HMR doesn't work with the extract-text-webpack-plugin (full reload only in watch mode)
Activity
[-][2.1.0] Add CSS Module Support[/-][+][2.1.0] Add CSS Module Support (`postcss-modules`)[/+]felixsanz commentedon May 18, 2017
@michael-ciniawsky Looks like with 2.x my CSS modules are now broken. Is this related?
Is there a workaround? Thanks!
michael-ciniawsky commentedon May 18, 2017
@felixsanz Are you using
LoaderOptionsPluginin yourwebpack.config.js? Normally it shouldn't affect the CSS Modules implementation ofcss-loader, but this was claimed a few times now. #232 #222TrySound commentedon May 18, 2017
Shouldn't
postcss-modulesuse messages for output instead of callback for this feature?Btw, this works great in modular-css
felixsanz commentedon May 18, 2017
@michael-ciniawsky I'm using css-loader's
modules: trueoption. I'm not usingLoaderOptionsPluginanywhere. I'll continue in #232[-][2.1.0] Add CSS Module Support (`postcss-modules`)[/-][+][2.1.0] Add CSS Modules(`postcss-modules`)[/+][-][2.1.0] Add CSS Modules(`postcss-modules`)[/-][+][2.1.0] Add CSS Modules (`postcss-modules`)[/+]5 remaining items
michael-ciniawsky commentedon Oct 30, 2017
I don't think so, show your config
michael-ciniawsky commentedon Oct 30, 2017
When did it exactly stop working?
michael-ciniawsky commentedon Oct 30, 2017
You can't really use the
postcss-modulesplugin withwebpack. It purpose is for other build tools likegulp/grunt. CSS Modules are handled bycss-loaderwhich is responsible for exporting the locals correctlymichael-ciniawsky commentedon Oct 30, 2017
That's why this issue exists 😛
michael-ciniawsky commentedon Oct 30, 2017
You are using
postcss.config.jsatm ? Remove thepostcss-modulesplugin from it and change yourwebpack.config.jsto the following.Also remove your custom HMR Code from the component,
style-loaderadds the necessary HMR Code automatically. HMR doesn't work with theextract-text-webpack-plugin(full reload only in watch mode)michael-ciniawsky commentedon Nov 1, 2017
if (process.env.NODE_ENV !== 'production') { if (module.hot) { const reloadTheme = require('provide-theme').reloadTheme; module.hot.accept([ './root.css', './App.css', './Foo.css', './Bar.css' ], () => { reloadTheme('BasicTheme', { classes: { - ...require('./root.css'), + ...require('./root.css').default, - ...require('./App.css'), + ...require('./App.css').default, - ...require('./Foo.css'), + ...require('./Foo.css').default, - ...require('./Bar.css') + ...require('./Bar.css').default } }); }); } }michael-ciniawsky commentedon Nov 1, 2017
from.js
toCJS.js
toESM.js
michael-ciniawsky commentedon Nov 1, 2017
Otherwise please post your issue on e.g StackOverflow as it is unrelated to this issue and
postcss-loader