I'm attempting to use a series of loaders to extract all the SCSS files into one file with ExtractTextPlugin
. Within the series of loaders I have, I'm using the autoprefixer
plugin that is used within postcss-loader
. However, nothing seems to be getting prefixed!
My webpack config is as follows:
webpack.config.js
const path = require('path');
const autoprefixer = require('autoprefixer');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const config = {
context: __dirname,
entry: {
app: [
path.resolve(entrypath),
],
},
module: {
rules: [
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
'css-loader',
'sass-loader',
{
loader: 'postcss-loader',
options: {
plugins: () => [autoprefixer()]
}
}
]
}),
},
],
},
output: {
path: path.join(__dirname, '../app/assets/javascripts/generated/'),
},
plugins: [
new ExtractTextPlugin({
filename: 'compiled-draft-document-scss.css',
allChunks: true
}),
],
};
module.exports = config;
My output seems all good with the exception that none of the prefixes are added. Below are the relevant versions of packages I am using:
"extract-text-webpack-plugin": "3.0.1",
"webpack": "^3.1.0",
"style-loader": "^0.19.0",
"css-loader": "^0.23.1",
"moment": "^2.11.1",
"postcss-loader": "^0.10.1",
"sass-loader": "^6.0.6",
From postcss-loader
README:
Use it after
css-loader
andstyle-loader
, but before other preprocessor loaders like e.g.sass|less|stylus-loader
.
So your loader chain should be:
[
'css-loader',
{
loader: 'postcss-loader',
options: {
plugins: () => [autoprefixer()]
}
},
'sass-loader'
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With