我尝试了不同的devtool
设置:eval,inline-source-map,eval-source-map,cheap-eval-source-map,cheap-module-eval-source-map。我似乎能够生成文件名的唯一一个是eval
选项。
eval选项生成一个sourceURL,如下所示
webpack:///./src/resolvers.js
而所有其他选项似乎都会产生像
这样的sourceURLwebpack-internal:///1
我的目标是使用cheap-module-eval-source-map
选项。
这是webpack配置
var path = require("path")
var nodeExternals = require("webpack-node-externals")
module.exports = {
entry: "./src/index.js",
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "dist")
},
target: "node",
externals: [nodeExternals()],
module: {
rules: [
{
test: /\.gql$/,
use: "raw-loader"
}
]
},
resolve: {
alias: {
GQLSchema$: path.resolve(__dirname, "src/schema/types.gql"),
Utils: path.resolve(__dirname, "src/utils")
}
},
watch: true,
devtool: "cheap-module-eval-source-map"
}