Skip to content
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

How to extract the id mappings object for CSS modules? #185

Open
ecommpro opened this issue Aug 17, 2019 · 0 comments
Open

How to extract the id mappings object for CSS modules? #185

ecommpro opened this issue Aug 17, 2019 · 0 comments

Comments

@ecommpro
Copy link

I'm using CSS modules and server side rendering. I need to extract to a file the class mappings for my modules:

:local(.myClass) {
    background: red;
}
:local .myClass {
    color: green;
}
:local(.myClass .otherClass) {
    color: blue;
}

This creates the following code in the bundled js file:

/***/ (function(module, exports, __webpack_require__) {

eval("// extracted by extract-css-chunks-webpack-plugin\nmodule.exports = {\"myClass\":\"src-main__myClass--1e7fN\",\"otherClass\":\"src-main__otherClass--NQhbn\"};\n\n//# sourceURL=webpack:///./src/main.css?./node_modules/extract-css-chunks-webpack-plugin/dist/loader.js??ref--4-1!./node_modules/css-loader/dist/cjs.js??ref--4-2!./node_modules/postcss-loader/src!./node_modules/sass-loader/lib/loader.js");

/***/ }),

I need the contents of the eval on a separated file so I can read it from a server side language.

I'm not sure where's the best place to extract this informacion. I think I could hack the css-loader loader to retrieve the mappings, but maybe it makes more sense doing this job on extract-css-chunks-webpack-plugin, because it's extract-chunks related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant