CSS Modules classes removed in .vue file
See original GitHub issueWhen reporting a bug, please be sure to include the following:
- A descriptive title
- An isolated way to reproduce the behavior
- What version of
purgecss
you’re using, and the platform(s) you’re running it on:purgecss-webpack-plugin@^0.20.0
- The behavior you expect to see, and the actual behavior: Do not remove CSS Modules classes, but they are actually removed
reproduce repository: https://github.com/JounQin/blog/tree/purgecss branch: purgecss reproduce step:
Add a .env.local
file in project directory like following
NODE_ENV=development
APP_KEYS=APP_KEYS
GITHUB_TOKEN= # add an usable token for GitHub API
Then run yarn dev
to see correct UI and run yarn build && yarn start
to see generated version after purgecss enabled.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:9 (8 by maintainers)
Top Results From Across the Web
[PURGECSS]: Webpack 5 + VueJS + CSS modules stripping ...
When using CSS modules with VueJS and Webpack 5, all classes are removed from the CSS bundle. In the options for css-loader, ...
Read more >CSS modules in Vue <style> tags are not supported - YouTrack
WebStorm already support CSS modules for imported CSS files, so hopefully it can be extended to support the CSS modules inside of .vue...
Read more >CSS Modules - Vue Loader
CSS Modules is a popular system for modularizing and composing CSS. vue-loader provides first-class integration with CSS Modules as an alternative for ...
Read more >Vue.js Functional Base Components Powered by CSS Modules
Manually adding props for every possible modifier or state class can be cumbersome. And what's even worse is that we have to add...
Read more >Extracting Style CSS From Vue Components - Laracasts
The Vue Loader docs don't have anything listed for Webpack 5. ... all scoped scss styles in each components and build a single...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@jsnanigans I know classes with be compiled into hash string after building, so I title this issue
CSS Modules classes are removed
.And after reading purifycss-webpack’s suggestion about CSS Modules, I find out that I can simply set
localIdentName
to prefix with_
and addwhitelistPatterns: [/^_/]
option (I was thinkingwhitelist
andwhitelistPatterns
are matching source classnames 😂) and it works.Util a better solution to deal with CSS Modules, it can be documented as a workaround like
purifycss-webpack
.@jsnanigans Is that related to Vue only? CSS Modules can be used with any other frameworks, right?