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

Sourcemap settings for UglifyJsPlugin in build #336

Closed
wants to merge 1 commit into from
Closed

Sourcemap settings for UglifyJsPlugin in build #336

wants to merge 1 commit into from

Conversation

gerhardsletten
Copy link

We need {sourceMap:false} for UglifyJsPlugin to avoid local path showing up below sources and webpack in google chrome inspector. This also minify css files.

@KyleAMathews
Copy link
Contributor

Two quick notes. First, css files are already minified. We use css-loaders ?minify option to do that. Second, could you investigate if there's a way to just make sourcemaps use relative paths in the sourcemaps in production builds? Having sourcemaps can be pretty useful in production so I don't want to just kill them unless absolutely necessary.

Thanks for bring this up!

@gerhardsletten
Copy link
Author

gerhardsletten commented Jun 19, 2016

When I was using gatsby build the whitespace and comments was not removed like in one of the starter demo (view source)

I agree that source maps are useful, the main issue was trying to fix was that they exposed the home directory.. But I am not sure anyway if sourcemap are supposed to be included in production?

@LukeSheard
Copy link
Contributor

I'd maybe prefer to leave this as an option to pass rather than remove or keep them entirely. I personally like them in development (of course), but would prefer to remove them in production.

@gerhardsletten
Copy link
Author

Agree as well, this should be optional, but in build default behaviour maybe should be that css is minified and sourcemaps disabled. Do you have any thoughts on how this should be accomplice with gatsby-node.js so I could finalize this?

@KyleAMathews
Copy link
Contributor

It looks like this Webpack configuration lets us change how files are displayed in sourcemaps https://webpack.github.io/docs/configuration.html#output-devtoolmodulefilenametemplate

also http://stackoverflow.com/questions/34185748/how-to-make-webpack-sourcemap-to-original-files

So perhaps sourcemaps are on by default by instead of outputting an absolute path we output a path relative to the root directory of the site? Then in 1.0 it'll be far easier to expose configuration like adding an option to disable sourcemaps in production altogether.

Thoughts?

@f0rr0
Copy link

f0rr0 commented Sep 26, 2016

export function modifyWebpackConfig(config, env) {
  if (env === 'build-javascript') {
    config.merge({
      devtool: 'hidden-source-map'
    });
  }
  return config;
}

This hides refs to source map in production build. You could choose from all the options that webpack provides.

@KyleAMathews
Copy link
Contributor

This is pretty ancient. Happy to restart the discussion with a new PR

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

Successfully merging this pull request may close these issues.

4 participants