【发布时间】:2017-10-26 19:54:48
【问题描述】:
我正在尝试将我的 Angular 应用程序从 Webpack 1 迁移到 2。在遵循 here 和 here 的更改之后。现在我收到以下元数据错误:
Invalid configuration object. Webpack has been initialised using a
configuration object that does not match the API schema.
- configuration has an unknown property 'metadata'. These properties are valid:
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry, externals?, loader?, module?, name?, node?, output?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, stats?, target?, watch?, watchOptions? }
For typos: please correct them.
For loader options: webpack 2 no longer allows custom properties in configuration.
Loaders should be updated to allow passing options via loader options in module.rules.
Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader:
plugins: [
new webpack.LoaderOptionsPlugin({
// test: /\.xxx$/, // may apply this only for some modules
options: {
metadata: ...
}
})
]
但我不确定它指向哪个 webpack 配置文件,因为我有一个用于不同环境的配置文件。
在 webpack.common.js 中:
const METADATA = {
title:
baseUrl:
}
module.exports = {
metadata: METADATA,
...
}
在其他 webpack 文件(用于开发、本地、生产、测试)中,我定义了 const METADATA 和 module.exports 内部,我有
webpackMerge(commonConfig, {
metadata: METADATA,
...
}
【问题讨论】:
标签: javascript angular webpack webpack-2