grunt-closure-compiler
grunt-closure-compiler copied to clipboard
How to compile js files and put them into the same directory
I need to compile all files in js folder and put them into the same one with the same names. So I have the following structure:
So my compile-compiler task is:
'closure-compiler': {
js: 'js/*.js',
jsOutputFile: 'js/*
}
But I get the following error:
Duplicate input js\app.js
yes this is question - I cant setup this is only compiler - just looping is needed
@skotchio We recently configured this for our large project. We wanted to compile a .js file minify and put it back into the same path as the regular .js file. The following is how we achieved what you want:
'closure-compiler': {
// minify JS files in-place
compileInPlace: {
files: [
{
expand: true,
cwd: './',
src: [
'js/edit.js',
// ....more files
],
dest: './',
rename: function (dest, src) {
// NOTE : this is done so we can support files "abc.def.js" and preserve the ".def" part.
return dest + '/' + src.replace('.js', '.min.js');
}
}
],
options: {} // ... your options here
},
}
Based on the configuration above, it will take js/edit.js and closure compile it into a file called js/edit.min.js. Hope this helps you out!