最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to create a source map for WebPack? - Stack Overflow

programmeradmin2浏览0评论

My current webpack.config file

module.exports = {
    entry: "./entry.js",
    output: {
        devtoolLineToLine: true,
        sourceMapFilename: "./bundle.js.map",
        pathinfo: true,
        path: __dirname,
        filename: "bundle.js"
    },
    module: {
        loaders: [
            { test: /\.css$/, loader: "style!css" }
        ]
    },
};

I was reading here .html and found the following:

output.sourceMapFilename

[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.

I've added it above as you can see, but when my webpack watch runs, I don't see a map file?

How is this done?

My current webpack.config file

module.exports = {
    entry: "./entry.js",
    output: {
        devtoolLineToLine: true,
        sourceMapFilename: "./bundle.js.map",
        pathinfo: true,
        path: __dirname,
        filename: "bundle.js"
    },
    module: {
        loaders: [
            { test: /\.css$/, loader: "style!css" }
        ]
    },
};

I was reading here https://webpack.github.io/docs/configuration.html and found the following:

output.sourceMapFilename

[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.

I've added it above as you can see, but when my webpack watch runs, I don't see a map file?

How is this done?

Share Improve this question edited Jun 20, 2020 at 9:12 CommunityBot 11 silver badge asked Nov 18, 2015 at 17:13 Leon GabanLeon Gaban 39k122 gold badges348 silver badges550 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 16

There are two options here:

Using the CLI development shortcut along with your --watch option:

webpack -d --watch

or using the configuration devtool option in your webpack.config.js:

module.exports = {
    devtool: "source-map",
    entry: "./entry.js",
    output: {
        devtoolLineToLine: true,
        sourceMapFilename: "./bundle.js.map",
        pathinfo: true,
        path: __dirname,
        filename: "bundle.js"
    },
    module: {
        loaders: [
            { test: /\.css$/, loader: "style!css" }
        ]
    },
};
发布评论

评论列表(0)

  1. 暂无评论