es-css-modules icon indicating copy to clipboard operation
es-css-modules copied to clipboard

Example using this with a webpack

Open FDiskas opened this issue 8 years ago • 5 comments

Trying this to integrate this in webpack3. Is it posible? Could you please provide an example

FDiskas avatar Aug 16 '17 19:08 FDiskas

const esCssModules = require('es-css-modules');
...
            {
                test: /\.s?css$/,
                use: extractSass.extract({
                    use: [
                        {
                            loader: 'css-loader',
                            options: {
                                module: true,
                                sourceMap: true,
                                importLoaders: 1
                            }
                        },
                        {
                            loader: 'postcss-loader',
                            options: {
                                sourceMap: true,
                                plugins() {
                                    return [
                                        esCssModules({
                                            jsFiles: 'src/index.js',
                                        }),
                                        autoprefixer
                                    ];
                                }
                            }
                        },
                        {loader: 'resolve-url-loader'},
                        {loader: 'sass-loader', options: {sourceMap: true}}
                    ],
                    fallback: 'style-loader'
                })
            },

Getting error Module build failed: TypeError: esCssModules is not a function

FDiskas avatar Aug 16 '17 19:08 FDiskas

If I try to load module like const esCssModules = require('es-css-modules').default; then I get warning

Unknown error from PostCSS plugin. Your current PostCSS version is 6.0.9, but es-css-modules uses 5.2.17. Perhaps this is the source of the error below.

then some errors in build process like

ERROR in ./assets/scss/main.scss
Module build failed: ModuleBuildError: Module build failed: TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined

in main.scss nothing special :)

@import "~bootstrap-sass/assets/stylesheets/bootstrap";

currently using "postcss-loader": "^2.0.6"

Tried to downgrade to [email protected] warning disappeared but error still the same

FDiskas avatar Aug 16 '17 19:08 FDiskas

P.S. https://github.com/jacobp100/es-css-modules/blob/master/rollup.config.js#L5 according documentation

For Node.js: compile to a CommonJS module $ rollup main.js --format cjs --output bundle.js

FDiskas avatar Aug 16 '17 20:08 FDiskas

Related? https://github.com/babel/babel/issues/5893

FDiskas avatar Aug 16 '17 21:08 FDiskas

I'm not sure this can be run with webpack to be honest, but feel free to try and prove me wrong! It gets its own dependency graph, and generates files that are used by webpack. It was really intended to be run before webpack. Hope this helps!

jacobp100 avatar Aug 18 '17 07:08 jacobp100