我在这里做错了什么?
运行webpack -d --config webpack.config.js
捆绑文件时,请勿创建映射文件。
webpack.config.js
const path = require('path');
module.exports = {
mode: "development",
devtool: "inline-source-map",
entry: './server/server.ts',
output: {
filename: 'server.js',
path: path.resolve(__dirname, 'dist')
},
resolve: {
extensions: [ '.tsx', '.ts', '.js' ]
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
}
]
},
target: 'node',
node: {
console: true,
fs: 'empty',
net: 'empty',
tls: 'empty'
}
};
tsconfig.json
{
"files": [
"server/server.ts"
],
"include": [
"server/**/*.ts"
],
"compilerOptions": {
"module": "commonjs",
"noImplicitAny": true,
"target": "es6",
"outDir": "dist",
"rootDir": "server",
"sourceMap": true,
"baseUrl": ".",
"moduleResolution": "node",
"removeComments": true,
"typeRoots": [ "node_modules/@types" ],
"paths": {
"*": [
"node_modules/@types/*",
"./server/types/*"
]
}
}
}
server.js已创建,但缺少地图文件。我每次运行webpack -d --config webpack.config.js
时都没有创建地图文件。
版本:
webpack 4.5.0
tsloader 4.2.0
答案 0 :(得分:0)
devtool
设为inline-source-map
;因此,您的源映射作为注释包含在JS文件中。如果您要生成单独的地图文件,请将devtool
更改为sourcemap
。