我试图调试一个快速的apollo服务器应用程序,我正在努力解决什么是错误的。我已经启用了一个包含源映射并且加载器选项debug设置为true的Web包构建。
我的npm脚本输出我的webpack构建和一个url到调试器
"debug": "node --inspect ./node_modules/.bin/webpack --config ./webpack.dev.js"
我通过chrome://inspect
转到调试器,我可以查看我的代码,但是当我通过http://localhost:8080/graphiql
发送请求时,调试器中没有任何事情发生,请求正常进行。
这是我的webpack配置
const webpack = require("webpack");
const path = require("path");
const nodeExternals = require("webpack-node-externals");
const StartServerPlugin = require("start-server-webpack-plugin");
module.exports = {
entry: ["./server.js"],
watch: true,
mode: "development",
target: "node",
node: {
__filename: true,
__dirname: true
},
externals: [nodeExternals({ whitelist: ["webpack/hot/poll?1000"] })],
module: {
rules: [
{
test: /\.js?$/,
use: [
{
loader: "babel-loader",
options: {
babelrc: false,
presets: [["env", { modules: false }], "stage-0"],
plugins: ["transform-regenerator", "transform-runtime"]
}
}
],
exclude: /node_modules/
}
]
},
plugins: [
new StartServerPlugin("server.js"),
new webpack.NamedModulesPlugin(),
new webpack.LoaderOptionsPlugin({
debug: true
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.SourceMapDevToolPlugin({
filename: '[name].js.map'
}),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.DefinePlugin({
"process.env": { BUILD_TARGET: JSON.stringify("server") }
})
],
output: { path: path.join(__dirname, "dist"), filename: "server.js" }
};
我的问题是,我需要通过使用graphql服务器进行任何额外的操作才能正确设置源映射吗?
感谢任何帮助。
答案 0 :(得分:0)
我通过使用nodemon并同时在parrell中运行webpack配置来修复此问题
https://github.com/remy/nodemon
https://www.npmjs.com/package/concurrently
"debug": "concurrently \"webpack --config ./webpack.dev.js\" \"nodemon --inspect=9229 ./dist/server.js\""
我还补充道
devtool: 'eval-source-map'
到我的webpack配置以启用源映射。
我还从webpack配置中删除了启动服务器插件,基本上只有webpack构建和nodemon服务。