gpt4 book ai didi

javascript - DevTools 无法解析 SourceMap : webpack:///node_modules/sockjs-client/dist/sockjs. js.map

转载 作者:行者123 更新时间:2023-12-03 07:02:58 25 4
gpt4 key购买 nike

我正在尝试设置一个简单的 html/Js 页面。

我已经安装了 webpack 和 babel。我已经使用“build”和“start”脚本配置了 package.json 文件。

该页面运行良好,但警告:“DevTools 无法解析 SourceMap:webpack:///node_modules/sockjs-client/dist/sockjs.js.map”每次执行“npm run start”命令时都会出现,我可以'不要在 Chome Devtools 中调试我的代码

包.json:

{
"name": "my-proyect",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server --config ./webpack.config.js --mode development",
"build": "webpack --config ./webpack.config.js --mode production",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"babel-loader": "^8.1.0",
"html-webpack-plugin": "^4.0.3",
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3"
}
}

webpack.config.js
const HtmlWebpackPlugin = require('html-webpack-plugin')

module.exports = {
// 1
entry: './src/index.js',

///////// BABEL ///////////////
module: {
rules: [
{
test: /\.(js)$/,
exclude: /node_modules/,
use: ['babel-loader']
}
]
},
resolve: {
extensions: ['*', '.js']
},
////////////////////////
///////// Plugins ///////////
plugins: [
new HtmlWebpackPlugin({
title: 'Hello Webpack bundled JavaScript Project',
template: './src/index.html'
})
],
// 2
output: {
path: __dirname + '/dist',
publicPath: '/',
filename: 'bundle.js'
},
// 3
devServer: {
contentBase: './dist'
}
};

如果有人能指导我解决这个问题,我将不胜感激。

问候。

最佳答案

将此添加到 webpack 配置文件的顶部可能会有所帮助:

devtool: 'eval-source-map'

关于javascript - DevTools 无法解析 SourceMap : webpack:///node_modules/sockjs-client/dist/sockjs. js.map,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60923524/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com