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.

Use postcss-modules generated css repeated

See original GitHub issue

HI, Q1 I want to use postcss-modules compile my css files, but out of the css generated duplicate.

1. common.css .row { width : 100%; height : 100px; margin : 0; padding : 0; background-color : #000000; }

2. subCommon.css .row { composes : row from './components.css'; background-color : #ff0430; } 3. webpack config { test : /\.css$/, loader: ExtractTextPlugin.extract("style-loader", ["css-loader?postcss-modules&importLoaders=1&sourceMap", "postcss-loader?parser=postcss-scss"]) } 4. postcss-modules config postcss: function () { return [ psmodules({ generateScopedName: '[local]_[hash:base64:8]', getJSON : function (cssFileName, json) {} }), // cssnano(nanoConfig), ];

5 Compiled main.css file .row_3hpoIFeb { width : 100%; height : 2.66667rem; margin : 0; padding : 0; background-color : #000000; } .row_3hpoIFeb { width : 100%; height : 2.66667rem; margin : 0; padding : 0; background-color : #000000; } .row_3D79gLaJ { background-color : #ff0430; }

common.css the row => [row_3hpoIFeb] is compiled twice!

Q2 Postcss-modules and cssnano can not be used together, compile exception!?

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:10

github_iconTop GitHub Comments

2reactions
AlexGalayscommented, Mar 15, 2018

Tiny repro here : https://github.com/AlexGalays/repro-webpack-cssloader

Expected: Only two classes in the extracted dist/root.css Actual: One of the two classes is outputted twice.

Looks like the trigger is for a className to be imported both in JS (to be used as a className string) and CSS (via composes)

1reaction
blm768commented, May 5, 2022

This behavior seems to be fundamentally different from the original design intention, which seems to have been that composes would just tack the composed class name onto the export symbol instead of actually pulling in the composed class’s style rules. The actual CSS Modules spec underspecifies the behavior of composes, so it’s not clear to me whether there was an intentional change at some point.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use postcss-modules generated css repeated #32 - GitHub
HI, Q1 I want to use postcss-modules compile my css files, but out of the css generated duplicate. 1. common.css .row { width...
Read more >
Use postcss-modules generated css repeated - - Bountysource
HI, Q1 I want to use postcss-modules compile my css files, but out of the css generated duplicate. 1. common.css .row { width...
Read more >
How to use the postcss-modules function in postcss-modules
To help you get started, we've selected a few postcss-modules examples, based on popular ways it is used in public projects. Secure your...
Read more >
Using PostCSS Modules In PHP - OnPoint Plugins
This allows the postcss-modules to work inside the import processes generating separate JSON files for each module and giving us unique selectors for...
Read more >
What is PostCSS? How to Use Plugins to Automate CSS Tasks
PostCSS is a Node.js tool that transforms your styles using JavaScript plugins. It generates more downloads per week on NPM ...
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