postcss-loader: Not getting autoprefixer to work with extract-text-webpack-plugin
Hi,
I have a working dev config for my scss like this:
var autoprefixer = require('autoprefixer');
module: {
loaders: [
{
test: /\.scss$/,
loaders: ['style-loader', 'css-loader?sourceMap', 'postcss-loader', 'sass-loader?sourceMap']
}
]
},
sassLoader: {
includePaths: ['node_modules/normalize.css'],
precision: '8',
outputStyle: 'nested'
},
postcss: [ autoprefixer({ browsers: ['last 10 versions'] }) ]
Now I wanted to extract the css to a file when I build for production. I get a file with the config below. The problem is that the options for postcss (for instance autoprefixer) doesn’t get applied.
var autoprefixer = require('autoprefixer');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var extractCSS = new ExtractTextPlugin('bundle.css');
module: {
loaders: [
{
test: /\.scss$/,
loader: extractCSS.extract('style-loader', 'css-loader!postcss-loader!sass-loader')
}
]
},
sassLoader: {
includePaths: ['node_modules/normalize.css'],
precision: '8',
outputStyle: 'compressed'
},
postcss: [ autoprefixer({ browsers: ['last 10 versions'] }) ],
plugins: [
extractCSS
]
};
Can anyone see what I’m doing wrong? Thanks
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 17 (6 by maintainers)
@szykov
Just for getting started, but could you please use try using webpack 2 loader syntax inside
ExtractTextPlugin.extract()
?webpack.config.js
postcss.config.js
webpack.config.js
Thanks @JounQin and @badtant ! Both works!
or
@donpinkus right now: extractTextInstance.extract(‘style-loader’, [‘css-loader?-autoprefixer’, ‘postcss-loader’)
@michael-ciniawsky it worked, thanks. 👍
@badtant You should disable the
Minification
option of css-loader withcss?-minimize
.minification
I find the real reason of no prefix, it’s not the problem of
extract-text-webpack-plugin
. when build we useoptimize-css-assets-webpack-plugin
normally,optimize-css-assets-webpack-plugin
usecssnano
as default processor, andcssnano
removed all prefix, so autoprefixer seemed not work in production. we can config like this:the option of
autoprefixer: { disable: true }
will disable cssnano’s autoprefixer and saved prefixer that already exist by ourselves.also see the issue optimize-css-assets-webpack-plugin/issues/51
maybe some brother need this so I copy and attach this although this issue closed a long time ago.