0

我在这里做错了什么?

运行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地图文件都不会被创建。

版本:

网络包 4.5.0

tsloader 4.2.0

4

1 回答 1

0

devtool设置为inline-source-map;因此,您的源映射包含在 JS 文件中作为内联注释。如果要生成单独的地图文件,请更改devtoolsourcemap.

于 2018-04-10T00:48:43.260 回答