Angular / Webpack-输出文件的名称与输入文件的名称不同

时间:2018-12-13 07:59:49

标签: javascript angular typescript webpack angular-universal

我正在尝试使Angular Universal正常工作,但是我遇到了一个奇怪的问题,我无法解决问题。基本上,文件web.server.ts被编译为server.js而不是web.server.js,但是为什么呢? [name]属性中的filename是否不应该成为web.server

这是我的webpack代码:

const path = require('path');
const webpack = require('webpack');

const APP_NAME = 'web';

module.exports = {
  entry: {  server: './web.server.ts' },
  resolve: { extensions: ['.js', '.ts'] },
  mode: 'development',
  target: 'node',
  externals: [
    /* Firebase has some troubles being webpacked when in
       in the Node environment, let's skip it.
       Note: you may need to exclude other dependencies depending
       on your project. */
    /^firebase/
  ],
  output: {
    // Export a UMD of the webpacked server.ts & deps, for
    // rendering in Cloud Functions
    path: path.join(__dirname, `dist/${APP_NAME}-webpack`),
    library: 'app',
    libraryTarget: 'umd',
    filename: '[name].js'
  },
  module: {
    rules: [
      { test: /\.ts$/, loader: 'ts-loader' }
    ]
  },
  plugins: [
    new webpack.ContextReplacementPlugin(
      /(.+)?angular(\\|\/)core(.+)?/,
      path.join(__dirname, 'src'), // location of your src
      {} // a map of your routes
    ),
    new webpack.ContextReplacementPlugin(
      /(.+)?express(\\|\/)(.+)?/,
      path.join(__dirname, 'src'),
      {}
    )
  ]
}

工作文件:

enter image description here

输出文件:

enter image description here

0 个答案:

没有答案