Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have a more readable bundle.js with webpack (sourcemap)?


I'm trying to make my first webpack project and I cannot find a way to change the numeric keys, which represent the modules in my output bundle.js, to a descriptive string so it will be easier to trace it in the debugger...

I have tried output.chunkFilename and output.sourceMapFilename without success.

This is how my gulp task looks like:

gulp.task('webpack', function (done) {
webpack({
    entry: {
        app: paths.src + "/main.js",
        vendor: ['react/addons', 'lodash']
    },
    output: {
        path: paths.dist,
        filename: "bundle.js",
        sourceMapFilename: '[file].js'
    },
    plugins: [
        new webpack.optimize.CommonsChunkPlugin("vendor", 'vendor.bundle.js', Infinity)
    ]
}, function onWebpackComplete(err, stats) {
    if (err) throw new gutil.PluginError("webpack", err);
    done();
});
});

Is it even possible? am I using it wrong? Is there a better way?

Thanks!

like image 925
Amit Kaspi Avatar asked Aug 07 '15 13:08

Amit Kaspi


1 Answers

In your webpack.config.js file add exports.output.pathinfo = true

like image 157
Lior Shefer Avatar answered Oct 03 '22 20:10

Lior Shefer