简体   繁体   English

需要使用UglifyJsPlugin webpack禁用CSS的缩小而不是JS

[英]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. 我在webpack.config中有这个设置来加载我的css文件。 I need to disable minify on my css files only. 我只需要在我的css文件上禁用minify。

{
   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. 根据我一直在阅读的内容,将UglifyJsPlugin和css-loader混合在一起是导致CSS缩小的原因。 The problem is there are multiple bugs where it outputs invalid CSS. 问题是存在多个错误,它会输出无效的CSS。

it is still minifying my css despite these various attempts to disable for css. 尽管有各种尝试禁用css,它仍在缩小我的CSS。

How can disable minify for css but still minify my js files? 如何禁用minify for css但仍然缩小我的js文件?

so I have figured out what needs to be done. 所以我想出了需要做些什么。

when it comes to invalid CSS output, you need to add the 当谈到无效的CSS输出时,你需要添加

?-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. 这个属性 - 在文档中最小化说它将禁用缩小(它没有),但它确实修复了我得到的无效CSS问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM