I'm uglifying files with one to one mapping like this:
plugins: {
files: [{
expand: true,
src: '*.js',
cwd: 'Scripts/v1/Plugins',
dest: 'Scripts/v1/Build/Plugins',
ext: '.min.js'
}]
},
And this works fine, until i start naming my files with multiple dots in filename.
So above script will uglify
4 files:
plugins.a.js
plugins.b.js
plugins.c.js
plugins.d.js
into one file:
plugins.min.js
while I expect:
plugins.a.min.js
plugins.b.min.js
plugins.c.min.js
plugins.d.min.js
Is this expected behavior or bug? In any case how can I keep one to one mapping with my naming convention.
Did you manage to find a solution for this? I checked all the issues in their github and apparently it should be fixed, but I'm still getting the same behavior with the latest builds.
EDIT: A solution was to pass a rename
function and manually create the filename
files: {
src: 'src/hp-lp-<%= pkg.version %>.js',
dest: 'src/',
expand: true,
flatten: true,
rename: function (dest, src) {
var folder = src.substring(0, src.lastIndexOf('/'));
var filename = src.substring(src.lastIndexOf('/'), src.length);
filename = filename.substring(0, filename.lastIndexOf('.'));
return dest + folder + filename + '.min.js';
}
}
It is currently the default expected behavior.
This has been brought up a few times with grunt:
From the first link, a change has been submitted to node globule that will let you select either first or last dot.
Other than that (or until that lands) you could use a rename function to get the behavior you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With