appthat
appthat

Reputation: 826

Need to disable minify of CSS but not JS using UglifyJsPlugin webpack

I have this setup in my webpack.config for loading my css files. I need to disable minify on my css files only.

{
   test: /\.sass$/,
   //loaders: ['style', 'css', 'sass']
   loader: ExtractTextPlugin.extract('style', 'css-loader!less-loader')
}

in my plugins i have:

new webpack.optimize.UglifyJsPlugin({
   exclude: [/file\.css$/],
   minimize: true
})

Based on what I have been reading mixing UglifyJsPlugin and css-loader together is what causes the minifying of CSS. The problem is there are multiple bugs where it outputs invalid CSS.

it is still minifying my css despite these various attempts to disable for css.

How can disable minify for css but still minify my js files?

Upvotes: 3

Views: 3250

Answers (1)

appthat
appthat

Reputation: 826

so I have figured out what needs to be done.

when it comes to invalid CSS output, you need to add the

?-minimize    
loader: ExtractTextPlugin.extract('style', 'css-loader?-minimize!less-loader')

This attribute -minimize in the docs says it will disable minification (which it doesnt), but it did fix the invalid CSS issues I was getting.

Upvotes: 4

Related Questions