grunt-usemin
grunt-usemin copied to clipboard
The default js flow should concat or uglify but not both
By default here is the sample of generated config:
concat:
{ generated:
{ files:
[ { dest: '.tmp/concat/app.js',
src: [ 'src/js/a.js', 'src/js/b.js', 'src/js/c.js' ] } ] } }
uglify:
{ options: { sourceMap: true },
generated: { files: [ { dest: 'dist/app.js', src: [ '.tmp/concat/app.js' ] } ] } }
The concat is unnecessary because uglify can take multiple sources.
There are also has negative side-effects, when enabling uglify sourcemaps, you get:
{
"version": 3,
"sources": ["../.tmp/concat/app.js"],
"names": ["yo", "Error", "aye", "document", "write", "bee", "console", "log"],
"mappings": "AASA,QAASA,MACP,KAAM,IAAIC,OAAM,SATlB,GAAIC,KAAM,UACVC,UAASC,MAAMF,IAGf,IAAIG,KAAM,eACVF,UAASC,MAAMC,KAQfC,QAAQC,IAAI,OAEZD,QAAQC,IAAI,QAEZP",
"file": "app.js"
}
Note sources
, this is a bummer: ../.tmp/concat/app.js
When disabling the concat, the generated config is just:
uglify:
{ options: { sourceMap: true },
generated:
{ files:
[ { dest: 'dist/app.js',
src: [ 'src/js/a.js', 'src/js/b.js', 'src/js/c.js' ] } ] } }
And the sourcemap is correct:
{
"version": 3,
"sources": ["../src/js/b.js", "../src/js/a.js", "../src/js/c.js"],
"names": ["yo", "Error", "aye", "document", "write", "bee", "console", "log"],
"mappings": "AAKA,QAASA,MACP,KAAM,IAAIC,OAAM,SCLlB,GAAIC,KAAM,UACVC,UAASC,MAAMF,IDDf,IAAIG,KAAM,eACVF,UAASC,MAAMC,KEDfC,QAAQC,IAAI,OAEZD,QAAQC,IAAI,QAEZP",
"file": "app.js"
}
Is there any reason to use concat at all? Can it be removed from the flow?