Skip to content

Instantly share code, notes, and snippets.

@phun-ky
Last active July 10, 2018 10:51
Show Gist options
  • Save phun-ky/766e5ec9f75eac61c945273a951f0c0b to your computer and use it in GitHub Desktop.
Save phun-ky/766e5ec9f75eac61c945273a951f0c0b to your computer and use it in GitHub Desktop.
webpack + postcss + extract-text-plugin = no CSS duplicates
postcss: () => {
return [
cssnano({
reduceIdents: false,
discardDuplicates: true,
autoprefixer: true
})
];
},modules: {
loaders: [{
test: test_expressions.css,
loader: extractTextPlugin.extract('css-loader?importLoaders=1!postcss-loader')
},{
test: test_expressions.stylus,
loader: extractTextPlugin.extract('css-loader?importLoaders=2!postcss-loader!stylus-loader')
}]
},
plugins: [
new extractTextPlugin('[name].css'),
new OptimizeCssAssetsPlugin({
assetNameRegExp: /\.css$/
})
]
@phun-ky
Copy link
Author

phun-ky commented Jan 16, 2017

If you want to use this in dev, you will have to use a plugin like write-file-webpack-plugin to force webpack to write the file to disk in dev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment