gulp-bundle-assets icon indicating copy to clipboard operation
gulp-bundle-assets copied to clipboard

Add ability to use source maps on js only

Open kinkay716 opened this issue 9 years ago • 3 comments

Im running into a double sourcemap issue since my gulp-sass has mappings for .scss -> .css and then the bundler has source maps from bundle -> .css. In the browser, you see many mappings for css. I would like to turn off mapping for css when bundling. the current options of 'maps' is a blanket on or off for both css and js.

kinkay716 avatar Jun 08 '15 18:06 kinkay716

as a work around, can you simple create two separate bundles? One for your js and one for css?

bundle: {
  'main-js': {
    scripts: [
      './js/app.js'
    ],
    options: {
      // ...
    }
  },
  'main-css-no-maps': {
    styles: [
      './styles/legacy.css',
      './styles/main.scss'
    ],
    options: {
      maps: false // disable sourcemaps
    }
  }
}

chmontgomery avatar Jun 08 '15 20:06 chmontgomery

yes...but hesitant to do so. I'm working on a fairly large app and my bundle.config is already 1400+ lines. If that is the only way, I understand. I'm surprised nobody has brought this up before? This would seem to be a pretty common use case.

kinkay716 avatar Jun 08 '15 21:06 kinkay716

Any file that is 1400+ lines long is going to be impossible to manage... my first suggestion would be to refactor your bundle.config so that each bundle is in it's own file and then the main bundle.config can require or loop through and include the separate files. You can also use a default set of options and merge them with custom ones for each bundle using something like _. defaults. Refactoring is your friend.

That problem aside, I'm not opposed to calling out the maps flag for scripts and styles separately. We already do that for many other options. It would look something like this:

'my-bundle': {
  // ...
  options: {
    maps: {
      scripts: true,
      styles: false
    }
  }
}

I would love a PR. Otherwise, I can't guarantee when this would get added...

chmontgomery avatar Jun 08 '15 21:06 chmontgomery