0

I am writing a simple program using webpack. I want to view the sourcemap (.map) file generated by webpack. This is my webpack configuration

var path = require('path');
var webpack = require('webpack');

module.exports = {
    context: path.resolve('src'),
    entry: {
        app: './app.jsx',
        vendor: './vendor.js',
    },
    output: {
        path: path.resolve('build'),
        filename: '[name].js',
        publicPath: '/public/assets',
        sourceMapFilename: 'source.map'
    },
    resolve: {
        // only discover files that have those extensions
        extensions: ['.ts', '.js', '.jsx', '.json', '.css', '.scss', '.html'],
    },
    module: {
        loaders: [{
            test: /\.jsx$/,
            exclude: /node_modules/,
            loader: 'babel-loader'
        },
        {
            test: [/\.css$/, /\.scss$/],
            loader: 'style-loader!css-loader?modules=true&localIdentName=[name]__[local]___[hash:base64:5]'
        }]
    },
    plugins: [
        new webpack.optimize.UglifyJsPlugin({
            compress: {
                warnings: false
            }
        }),
    ],
    devServer: {
        historyApiFallback: {
            index: 'index.html'
        },
    },
    devtool: 'source-map'
}

However when I run build, I see only the app.js and vendor.js file. No .map file is generated. How do I view the .map file.

The second question is that even without the .map file Chrome is able to show the actual source files, how do it do this without the actual .map file?

tmp dev
  • 8,043
  • 16
  • 53
  • 108
  • 1Q: Ans source map added in you file in bottom like this //# sourceURL = foo.js 2Q Ans : with out souremap chrome is not able to show the actual source files – Kasiriveni Apr 26 '17 at 04:57
  • How do I get it to generate a different sourcemap? – tmp dev Apr 26 '17 at 04:59
  • output.sourceMapFilename The filename of the SourceMaps for the JavaScript files. They are inside the output.path directory. [file] is replaced by the filename of the JavaScript file. [id] is replaced by the id of the chunk. [hash] is replaced by the hash of the compilation. Default: "[file].map" – Kasiriveni Apr 26 '17 at 05:07
  • Taking the above webpack file even when I run the build command I do not get the .map file. – tmp dev Apr 26 '17 at 05:11
  • try below the commands webpack-dev-server -d or webpack -d – Kasiriveni Apr 26 '17 at 05:29
  • Still did not work, can you give me a sample webpack.config.js file that works with this. – tmp dev Apr 26 '17 at 23:00

0 Answers0