角度无效配置(Webpack) [英] Angular invalid configuration(Webpack)
本文介绍了角度无效配置(Webpack)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在学习角度学习约一个月.我正在跟踪我在互联网上找到的一系列视频.我陷入了这个错误,如下图所示.
I am learning angular for about a month. I am following a series of video that I've found in internet. I got stuck here in this error as shown in picture below.
webpack.server.config.js代码
const path = require('path');
const webpack = require('webpack');
module.exports = {
entry: { server: './server.ts' },
resolve: { extentions: ['.js', '.ts'] },
externals: [/{node_modules|main\..*\.js}/],
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js'
},
module: {
rules: {
test: /\.ts$/,
loader: 'ts-loader'
}
},
plugins: [
new webpack.ContextReplacementPlugin(
/(.+)?angular(\\|\/)core(.+)?/,
path.join(__dirname, 'src'),
{}
),
new webpack.ContextReplacementPlugin(
/(.+)?express(\\|\/)(.+)?/,
path.join(__dirname, 'src'),
{}
)
]
}
Package.json
Package.json
推荐答案
错误消息中的提示就在那里. rules
必须是一个对象数组,而不是单个对象;和扩展名
拼写为 s
,其中还有第二个 t
.
The clues are right there in the error message. rules
needs to be an array of objects, not a single object; and extensions
is spelled with an s
where you have a second t
.
这是固定版本:
webpack.server.config.js代码
const path = require('path');
const webpack = require('webpack');
module.exports = {
entry: { server: './server.ts' },
resolve: { extensions: ['.js', '.ts'] }, // CHANGED
externals: [/{node_modules|main\..*\.js}/],
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js'
},
module: {
rules: [{ // CHANGED
test: /\.ts$/,
loader: 'ts-loader'
}] // CHANGED
},
plugins: [
new webpack.ContextReplacementPlugin(
/(.+)?angular(\\|\/)core(.+)?/,
path.join(__dirname, 'src'),
{}
),
new webpack.ContextReplacementPlugin(
/(.+)?express(\\|\/)(.+)?/,
path.join(__dirname, 'src'),
{}
)
]
}
这篇关于角度无效配置(Webpack)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文