Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to customize the “sources” field in the sourcemaps. #283

Open
stanch opened this issue Jan 8, 2015 · 4 comments
Open

Allow to customize the “sources” field in the sourcemaps. #283

stanch opened this issue Jan 8, 2015 · 4 comments

Comments

@stanch
Copy link

stanch commented Jan 8, 2015

Currently the sources field in sourcemaps is always relative to the sources. In my case it looks somewhat ugly:

../../../../src/main/webapp/home/scripts/home.js

I’m including the sources with sourcesContent and not serving the actual sources (and if I were serving them, it wouldn’t be at that path...).

Is there an option to tweak that relative path? uglify.js mentions -p/--prefix, but as far as I can see it’s not available from this plugin. I also tried sourceMapRoot, but it did nothing.

My base setup is like this:

uglify: {
  options: {
    sourceMap: true,
    sourceMapIncludeSources: true,
    compress: true,
    mangle: true
  },
  build: {
    files: [{
      /* Minify all but vendor scripts */
      expand: true,
      cwd: 'src/main/webapp/home',
      src: ['scripts/**/*.js', '!scripts/vendor/**'],
      dest: 'target/grunt/home'
    }]
  }
}
@vladikoff
Copy link
Member

This feature might be useful yeah. A workaround right now is to write a simple task that does something like:

var updateMap = JSON.parse(fs.readFileSync(SOURCEMAP_PATH));
updateMap.sources = ['some-path.js'];
fs.writeFileSync(SOURCEMAP_PATH, JSON.stringify(updateMap));

@monolithed
Copy link

+1

2 similar comments
@derzwen
Copy link

derzwen commented Feb 4, 2015

+1

@sebastientromp
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants