Skip to content

CSS Modules no longer work #460

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

Closed
tmalley99 opened this issue Nov 26, 2018 · 8 comments · Fixed by #508
Closed

CSS Modules no longer work #460

tmalley99 opened this issue Nov 26, 2018 · 8 comments · Fixed by #508
Labels

Comments

@tmalley99
Copy link

Hey guys!

Just updated encore to latest version and noticed that VueLoader css modules no longer are being generated (raw classnames are being generated instead and $style.className no longer returns appropriate class)...

Was there something changed that broke CSS modules or is this an error?

Thanks!

@weaverryan
Copy link
Member

Hey @Chesskingt!

Thanks for the report! Yes and no :). We did upgrade to Webpack 4 internally, and there could be some bug related to that, or you may be using a version of vue-loader (what version of vue, vue-loader and vue-template-compiler are in your project) that's not playing nicely.

Could you post your exact code and the expected output? We could turn that into a test case and find out easily if there is a bug or not.

Cheers!

@tmalley99
Copy link
Author

Sorry for delay, here's the specs (still an issue)

"axios": "^0.18.0", "bootstrap": "^4.2.1", "node-sass": "^4.11.0", "sass-loader": "^7.1.0", "v-tooltip": "^2.0.0-rc.33", "vue": "^2.5.21", "vue-loader": "^15.5.1", "vue-spinner": "^1.0.3", "vue-template-compiler": "^2.5.21"

@tmalley99
Copy link
Author

@Lyrkan
Copy link
Collaborator

Lyrkan commented Jan 20, 2019

Hi @Chesskingt,

Did you enable CSS modules using configureCssLoader()?

Encore.configureCssLoader(options => {
  options.modules = true;
});

@tmalley99
Copy link
Author

hi! Before, that worked right in Vue. Now, doing that works, BUT, there's an issue where ALL my css is now modualized. I use twig and Bootstrap so modularizing everything isn't an option. What ever happened to the basic vue-loader support for CSS modules within encore?

@Lyrkan
Copy link
Collaborator

Lyrkan commented Jan 20, 2019

Well, it seems that it now requires a more advanced config: https://vue-loader.vuejs.org/guide/css-modules.html#opt-in-usage

We may be able to add that to the /\.css$/ rule generated by Encore (see here and here) but we'll have to check if it doesn't break anything else first...

@epcliff
Copy link

epcliff commented Feb 1, 2019

Hi! I have a similar issue. I added configureCssLoader and it's no longer empty but my tailwind css have been changed. Is there any other configuration I need to do?

@Lyrkan
Copy link
Collaborator

Lyrkan commented Feb 1, 2019

Hi @epcliff,

It's probably the same issue.

As I noted in my previous comment using "standard" CSS and CSS modules at the same time requires a more advanced configuration... which isn't easy to achieve in the current version of Encore (you would have to remove the default CSS loader and add the config given on Vue's website...)

I tried something in #508 that should help with that.

@Lyrkan Lyrkan added Bug Bug Fix HasPR labels Feb 1, 2019
weaverryan pushed a commit that referenced this issue Feb 2, 2019
This PR was merged into the master branch.

Discussion
----------

Support CSS modules in Vue.js projects by default

With the current version of Encore you are able to either:

* only use standard CSS (default behavior)
* only use CSS modules (by calling `Encore.configureCssLoader()`)

This PR should help detecting when `<style module>` is used and enabling css modules accordingly (fixes #460).

**Reference:** https://vue-loader.vuejs.org/guide/css-modules.html#opt-in-usage

Commits
-------

356e538 Support CSS modules in Vue.js projects by default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants