我正在尝试使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'),
{}
)
]
}
工作文件:
输出文件: