Webpack-dev-server doesn't generate source maps

怎甘沉沦 提交于 2019-11-28 20:03:56

Use webpack -d

The d flag stands for development shortcut and it enables all of your developer tools such as source maps.

Use webpack-dev-server -d

  • -d is shorthand for --debug --devtool source-map --output-pathinfo.
  • output-pathinfo adds comments to the generated bundle that explain what module/files are included in what places. So in the generated code, the comment is added to this line of code: require(/* ./test */23) which says that 23 is pointing to the test module. This is mostly helpful when you're looking at the code Webpack has generated, and not so much when stepping through the debugger. I got this example from this relevant bit of documentation.

  • This all works because webpack-dev-server accepts all the same flags as webpack.

  • See this section in the docs for details.

Tips & gotchas

  • --content-base - by default the dev server will serve files in the directory you run the command in. If your build files are in build/, you need to specify --content-base build/ so the dev server will serve up files in the build directory
  • --inline - auto-reload whenever you save a file with some changes!

Add {devtool:"source-map"} to your webpack.config.js

See more here

Kostya Harutyunyan

Please add in you webpack.config.js file the following`

devtool: "#inline-source-map",

You can find clear information about it from the site of webpack` https://webpack.github.io/docs/configuration.html

Also please find attached screenshot of sourcemap part, from webpack site.

All I did is change:

// package.json
{
    ...
    **from** "dev:serve": "webpack-dev-server",
    **to** "dev:serve": "webpack-dev-server -d",
    ...
}

Equivalent to: $ webpack-dev-server -d

Now I can utilize Ctrl + p in Chrome and I see my ES6 syntax to set breakpoints on.

Info

$ webpack-dev-server --version
webpack-dev-server 2.9.7
webpack 3.10.0
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!