I raised this issue at extract-text-webpack-plugin but it seems this plugin doesn't support this feature at the moment (I'm not sure).
How can I extract main.scss
and home.scss
into main.css
and home.css
in the following example?
Result: There was no error, but only home.css
was created.
home.js
import '../scss/main.scss';
import '../scss/home.scss';
main.scss
.test1 { color: #f00; }
home.scss
.test2 { color: #00f; }
webpack.config.js
let webpack = require('webpack');
let ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
module: {
rules: [{
test: /\.js$/,
exclude: /node_modules/,
use: 'babel-loader'
}, {
test: /\.scss$/,
use: ExtractTextPlugin.extract(['css-loader', 'sass-loader'])
}]
},
entry: {
'home': './scripts/home.js'
},
output: {
filename: '[name].js',
path: __dirname + '/static/scripts',
publicPath: '/static/'
},
plugins: [
new ExtractTextPlugin('../css/[name].css')
]
};