admin管理员组文章数量:1417584
I'm building an application with Webpack and Babel. When the application runs into an error, it correctly lists the line number for the first error but then shows the line number for the minified code for each subsequent step.
My Webpack config is as follows,
const webpack = require('webpack');
const path = require('path');
module.exports = {
module: {
loaders: [
{
loader: "babel-loader",
exclude: [
/(node_modules)/,
],
query: {
presets: ['es2015','react'],
plugins: ['transform-object-rest-spread']
}
},
{
test:/\.less$/,
exclude:'/node_modules',
loader:"style!css!less"
}
]
},
entry: {
"index": ["./src/main"]
},
output: {
path: path.resolve(__dirname, "public"),
publicPath: "/assets",
filename: "[name].bundle.js"
},
resolve: {
extensions: ['', '.js', '.jsx'],
},
devServer: { inline: true },
devtool: 'source-map'
};
I'm building an application with Webpack and Babel. When the application runs into an error, it correctly lists the line number for the first error but then shows the line number for the minified code for each subsequent step.
My Webpack config is as follows,
const webpack = require('webpack');
const path = require('path');
module.exports = {
module: {
loaders: [
{
loader: "babel-loader",
exclude: [
/(node_modules)/,
],
query: {
presets: ['es2015','react'],
plugins: ['transform-object-rest-spread']
}
},
{
test:/\.less$/,
exclude:'/node_modules',
loader:"style!css!less"
}
]
},
entry: {
"index": ["./src/main"]
},
output: {
path: path.resolve(__dirname, "public"),
publicPath: "/assets",
filename: "[name].bundle.js"
},
resolve: {
extensions: ['', '.js', '.jsx'],
},
devServer: { inline: true },
devtool: 'source-map'
};
Share
Improve this question
edited Mar 12, 2017 at 11:59
Madara's Ghost
175k50 gold badges272 silver badges314 bronze badges
asked Mar 12, 2017 at 11:51
Code WhispererCode Whisperer
23.7k22 gold badges72 silver badges88 bronze badges
2
- AFAIU, you are debugging in minified build, isn't it? What help are you exactly asking? Please be specific. – Anvesh Checka Commented Mar 13, 2017 at 6:42
- Possible duplicate of webpack-dev-server: how to get error line numbers of orignal files – Michael Freidgeim Commented Nov 6, 2019 at 12:34
1 Answer
Reset to default 5In order to debug from webpack generated builds, you need to understand little bit more about 'devtool' setting in webpack. Here is the link to the official documentation. Webpack Devtool Configuration
Now ing to your problem, you can use either of these below in order to navigate to your original piece of code which caused the problem. This is possible only using sourcemaps.
eval-inline-source-map //For DEV builds
or
cheap-inline-module-source-map //For PROD builds
E.g.,
{
'devtool': 'cheap-inline-module-source-map'
}
本文标签: javascriptWebpackBabel Wrong Line Numbers in Stack TraceStack Overflow
版权声明:本文标题:javascript - Webpack + Babel Wrong Line Numbers in Stack Trace - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745273048a2651012.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论