grunt-usemin icon indicating copy to clipboard operation
grunt-usemin copied to clipboard

The default js flow should concat or uglify but not both

Open beck opened this issue 9 years ago • 1 comments

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"
}

beck avatar Dec 23 '15 23:12 beck

Is there any reason to use concat at all? Can it be removed from the flow?

jgogstad avatar Jan 29 '16 09:01 jgogstad