How to use sass loader with webpack 4? I read a lot about this and most sites recomended to use ExtractTextPlugin, but ExtractTextPlugin doesn't work with webpack 4.
I wrote following webpack.config.js:
const path = require('path');
const ClosureCompilerPlugin = require('webpack-closure-compiler');
module.exports = {
module: {
rules: [
{
test: /\.scss$/,
use: [{
loader: "style-loader"
}, {
loader: "css-loader"
}, {
loader: "sass-loader"
}]
}
]
},
plugins: [
new ClosureCompilerPlugin({
compiler: {
language_in: 'ECMASCRIPT6',
language_out: 'ECMASCRIPT3',
compilation_level: 'ADVANCED'
},
concurrency: 3,
})
]
};
Output .js file works well, but my .scss didn't compile to css. I'm tried to add entry points:
entry: {
stylesheet: path.resolve('src', 'scss/styles.scss'),
main: path.resolve('src', 'index.js')
}
and after this my styles.scss compiles to stylesheet.js, but i not to .css.
stylesheet: path.resolve('src', 'scss/styles.scss'),
to myentry
in config file and i recive main.js, main.css and stylesheet.js(why?). I'm trying to require my styles insideindex.js
, but it always error(can't find module). – Fastening