Closed pronebird closed 7 years ago
@pronebird which version of this plugin are you using? If it is newest, could you try downgrade to 1.1.0
?
It's 1.2.0
npm list babel-plugin-css-modules-transform
electron-react-redux-boilerplate@0.0.0 /Users/pronebird/test
└── babel-plugin-css-modules-transform@1.2.0
Same issue with 1.1.0. First change is OK, subsequent calls do not generate combined CSS.
It's cache issue in requireCssFile
.
You have to invalidate cache for CSS file as following:
delete require.cache[filePathOrModuleName];
I think it is caused by this line https://github.com/michalkvasnicak/babel-plugin-css-modules-transform/blob/master/src/index.js#L95
It's not cache issue if you enable devMode
. https://github.com/css-modules/css-modules-require-hook#devmode-boolean
Could you try to brute force change source for this plugin in the node_modules
so you will workaround the line I sent you? It is faster way how to check if everything works :)
Yeah yeah that's what I am doing right now. I've enabled devMode
, gonna erase node_modules and reinstall from scratch then try couple of things you suggested. I had this commented out too... https://github.com/michalkvasnicak/babel-plugin-css-modules-transform/blob/master/src/index.js#L95
I think that should solve the problem because we are not writing css again if a css file is transpiled.
You're right! With devMode
on and line #95 commented everything works as expected when using babel --watch
Ok so we should change the line so it only checks cache if devMode
is enabled, otherwise it will ignore changes in css files.
I am sorry I mean opposite, to check it only if devMode
is disabled.
Is it safe to assume that if this thing is called more than once then the same class-set is produced? I mean are CSS class names deterministic or randomized on each compilation?
I think they are generated based on css rules. So unless you don't have hashes in css names I think class names changes with rules in their definitions. But I am not sure (not an expert to css modules).
I meant unless you have set css class name generator to ignore hashes you should have unique css classes.
@pronebird could you try version next
please? #38
@michalkvasnicak good progress! I'll take a look at it on monday.
Released in 1.2.6
. Is not tested properly so maybe bugs will occur.
For some unknown reason extracted CSS is only saved to disk once. All subsequent changes to CSS are no-op.
NODE_ENV
is set todevelopment
.Config:
This is the log from browser-sync:
I wrote a somewhat test to verify that there is no issue with CSS compiler. Looking at console output everything is alright.
I first run babel to precompile everything with the following options:
Then I run two scripts in parallel:
Script that spins off Browser sync to reload browser on file changes:
Babel with
--watch
option to recompile files on fly: