3

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?

2
  • 1
    UglifyJsPlugin is for JS btw, not CSS. Commented Sep 6, 2016 at 22:56
  • 1
    mixing UglifyJsPlugin and css-loader together causes webpack to minify CSS. There must be an option to disable CSS minify, but havnt found it yet Commented Sep 6, 2016 at 23:34

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

It will also work including the css in the bundle.js. { test: /\.css$/, loader: 'style-loader!css-loader?-minimize&-autoprefixer!postcss-loader', }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.