es-css-modules
es-css-modules copied to clipboard
Example using this with a webpack
Trying this to integrate this in webpack3. Is it posible? Could you please provide an example
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
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
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
Related? https://github.com/babel/babel/issues/5893
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!