我尝试将我的角度应用程序从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,
...
}