can not find the source map file when use UglifyJsPlugin #81

Closed
plantain-00 opened this Issue Oct 17, 2015 · 8 comments

Comments

Projects
None yet
6 participants
@plantain-00
gulp.task('test', function() {
    gulp.src('frontends/scripts/index.js')
        .pipe(webpack({
            plugins: [
                new webpack.webpack.optimize.UglifyJsPlugin({ minimize: true, sourceMap: true })
            ]
        }))
        .pipe(rename("index.min.js"))
        .pipe(gulp.dest('frontends/build/scripts/'));
});

The index.min.js is created and minified properly, but I can not find any source map file.
And there is no //# sourceMappingURL=index.min.map at the end of index.min.js file.
Considering UglifyJsPlugin does have sourceMap option, is this a bug of webpack-stream?

@shama

This comment has been minimized.

Show comment
Hide comment
@shama

shama Oct 17, 2015

Owner

webpack will output multiple destination files. Are you sure .pipe(rename("index.min.js")) isn't just renaming both of the output files to index.min.js by mistake?

Owner

shama commented Oct 17, 2015

webpack will output multiple destination files. Are you sure .pipe(rename("index.min.js")) isn't just renaming both of the output files to index.min.js by mistake?

@plantain-00

This comment has been minimized.

Show comment
Hide comment
@plantain-00

plantain-00 Oct 17, 2015

@shama rename does not change this situation:

gulp.task('test', function() {
    gulp.src('frontends/scripts/index.js')
        .pipe(webpack({
            plugins: [
                new webpack.webpack.optimize.UglifyJsPlugin({ minimize: true, sourceMap: true })
            ]
        }))
        //.pipe(rename("index.min.js"))
        .pipe(gulp.dest('frontends/build/scripts/'));
});

There is only one file named 10fedf2665417c01a8c3.js, minified properly, no source map file, no //# sourceMappingURL=XXXX.map in 10fedf2665417c01a8c3.js.

@shama rename does not change this situation:

gulp.task('test', function() {
    gulp.src('frontends/scripts/index.js')
        .pipe(webpack({
            plugins: [
                new webpack.webpack.optimize.UglifyJsPlugin({ minimize: true, sourceMap: true })
            ]
        }))
        //.pipe(rename("index.min.js"))
        .pipe(gulp.dest('frontends/build/scripts/'));
});

There is only one file named 10fedf2665417c01a8c3.js, minified properly, no source map file, no //# sourceMappingURL=XXXX.map in 10fedf2665417c01a8c3.js.

@shama

This comment has been minimized.

Show comment
Hide comment
@shama

shama Oct 17, 2015

Owner

@plantain-00 Try using webpack's source map setting instead:

.pipe(webpack({
  plugins: [
    new webpack.webpack.optimize.UglifyJsPlugin({ minimize: true })
  ],
  devtool: 'source-map'
}))

Here are docs on more options with webpack's devtool: https://webpack.github.io/docs/configuration.html#devtool

Owner

shama commented Oct 17, 2015

@plantain-00 Try using webpack's source map setting instead:

.pipe(webpack({
  plugins: [
    new webpack.webpack.optimize.UglifyJsPlugin({ minimize: true })
  ],
  devtool: 'source-map'
}))

Here are docs on more options with webpack's devtool: https://webpack.github.io/docs/configuration.html#devtool

@plantain-00

This comment has been minimized.

Show comment
Hide comment
@plantain-00

plantain-00 Oct 17, 2015

@shama it works, thanks.

@shama it works, thanks.

@bennyn

This comment has been minimized.

Show comment
Hide comment
@bennyn

bennyn Aug 30, 2016

Using webpack 2.1.0-beta.21, I needed to set sourceMap: true on webpack.optimize.UglifyJsPlugin AND devtool: 'source-map'.

So in the end my configuration looked like this:

webpack.config.js

var webpack = require('webpack');

module.exports = {
  devtool: 'source-map',
  entry: {
    filename: './build/proteus.js'
  },
  output: {
    filename: 'proteus-bundle.js',
    library: 'proteus',
    libraryTarget: 'amd',
    path: './dist'
  },
  node: {
    fs: 'empty',
    crypto: 'empty'
  },
  externals: {
    'libsodium-native': 'libsodium_native'
  },
  plugins: [
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.UglifyJsPlugin({
      compress: {warnings: false},
      output: {comments: false},
      sourceMap: true
    })
  ]
};

bennyn commented Aug 30, 2016

Using webpack 2.1.0-beta.21, I needed to set sourceMap: true on webpack.optimize.UglifyJsPlugin AND devtool: 'source-map'.

So in the end my configuration looked like this:

webpack.config.js

var webpack = require('webpack');

module.exports = {
  devtool: 'source-map',
  entry: {
    filename: './build/proteus.js'
  },
  output: {
    filename: 'proteus-bundle.js',
    library: 'proteus',
    libraryTarget: 'amd',
    path: './dist'
  },
  node: {
    fs: 'empty',
    crypto: 'empty'
  },
  externals: {
    'libsodium-native': 'libsodium_native'
  },
  plugins: [
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.UglifyJsPlugin({
      compress: {warnings: false},
      output: {comments: false},
      sourceMap: true
    })
  ]
};
@shankie-san

This comment has been minimized.

Show comment
Hide comment
@shankie-san

shankie-san Sep 1, 2016

Hmmm I'm having the same issue, but when using webpack straight up, rather than in Gulp. I've tried all the solutions listed here, but to no avail!

I'll report back here if I discover anything...

Hmmm I'm having the same issue, but when using webpack straight up, rather than in Gulp. I've tried all the solutions listed here, but to no avail!

I'll report back here if I discover anything...

@alfonsoperez

This comment has been minimized.

Show comment
Hide comment

sourceMaps config parameter is now false by default
https://gist.github.com/sokra/27b24881210b56bbaff7#gistcomment-1863573

@kisenka

This comment has been minimized.

Show comment
Hide comment
@kisenka

kisenka Dec 9, 2016

It doesn't work with devtool: 'cheap-module-source-map'

kisenka commented Dec 9, 2016

It doesn't work with devtool: 'cheap-module-source-map'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment