1
我試圖將我的角度應用程序從Webpack 1遷移到2.在遵循here和here的更改之後。現在我發現了以下錯誤元數據:從Webpack 1遷移到2錯誤 - Angular(4.1.3)應用程序
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,
...
}
我跟着你提供的第二個鏈接(HtmlWebpackPlugin)工作。但我得到'commonConfig'不是一個函數。 'module.exports'應該是一個函數嗎? – user3344978
它不應該是一個功能,但我可以是一個功能。這是你需要文件時得到的。在回購作爲一個函數,使你可以通過選項,你可以看到第43行。 – ShabbY
我現在看到有關引導程序加載器的錯誤。不知道爲什麼,因爲我沒有明確地在配置文件中的任何地方使用它 – user3344978