question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CSS Modules classes removed in .vue file

See original GitHub issue

When 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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

6reactions
JounQincommented, Feb 1, 2018

@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 add whitelistPatterns: [/^_/] option (I was thinking whitelist and whitelistPatterns 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.

3reactions
JounQincommented, Feb 22, 2018

@jsnanigans Is that related to Vue only? CSS Modules can be used with any other frameworks, right?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found