gruntjs / grunt-contrib-cssmin

Compress CSS files.
http://gruntjs.com/
MIT License
793 stars 147 forks source link

Wrong output file name when dots are present #298

Open alex-zhuravok opened 6 years ago

alex-zhuravok commented 6 years ago

I have 3 files in directory: jquery.colorbox.css jquery.fileupload-ui.css jquery.selectbox.css

During minification they all be renamed to jquery.min.css and replaced each other, so I have only one file and it has wrong name.

JoelAlphonso commented 5 years ago

Same here

gongxw commented 4 years ago

我也遇到了同样的问题。然后,看了下源码。

在grunt的file.js中发现了如下代码:

`// The "ext" option refers to either everything after the first dot (default)

// or everything after the last dot.

var extDotRe = {

first: /(.[^\/]*)?$/,

last: /(.[^\/.]*)?$/,

};`

`// Change the extension?

if ('ext' in options) {

destPath = destPath.replace(extDotRe[options.extDot], options.ext);

}`

所以只需要在file配置中加上 extDot: 'last' 即可。

`files: [{

expand: true,

cwd: 'out/style/',

src: ['*.css', '!*.min.css'],

dest: 'out/style',

ext: '.min.css',

extDot: 'last'

}]`

希望可以给继续使用grunt的朋友一些帮助。