Javascript 从Webpack 1迁移到2错误-角度(4.1.3)应用程序

Javascript 从Webpack 1迁移到2错误-角度(4.1.3)应用程序,javascript,angular,webpack,webpack-2,Javascript,Angular,Webpack,Webpack 2,我正在尝试将我的angular应用程序从Webpack1迁移到Webpack2。在遵循和的更改之后。现在我在元数据方面遇到以下错误: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. - configuration has an unknown property 'metadata'. Thes

我正在尝试将我的angular应用程序从Webpack1迁移到Webpack2。在遵循和的更改之后。现在我在元数据方面遇到以下错误:

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,
   ...
}
在其他网页包文件(用于开发、本地、生产、测试)中,我定义了
const元数据
,并在
module.exports中定义了

webpackMerge(commonConfig, {
   metadata: METADATA, 
   ...
}

错误消息引用了传递到webpack的配置。我猜您使用webpackMerge是因为您有一个公共配置。因此,基本上它将引用所有配置文件,因为元数据不是允许的配置属性。 您可以找到一个成熟的配置。从配置中删除元数据属性时,错误消息应消失


如果您想在webpack配置中配置诸如标题或baseUrl之类的内容,可以像在中使用一样使用HtmlWebpackPlugin。

错误消息指的是传递到webpack的配置。我猜您使用webpackMerge是因为您有一个公共配置。因此,基本上它将引用所有配置文件,因为元数据不是允许的配置属性。 您可以找到一个成熟的配置。从配置中删除元数据属性时,错误消息应消失


如果您想在网页包配置中配置诸如标题或baseUrl之类的内容,可以像在中使用一样使用HtmlWebpackPlugin。

我遵循了您提供的第二个链接(HtmlWebpackPlugin)。但是我发现,
commonConfig
不是一个函数。
module.exports
应该是函数吗?它不应该是函数,但我可以是函数。这是你需要文件时得到的。在回购协议中,它是一个函数,因此您可以传递选项,如第43行所示。我现在看到与引导加载程序相关的错误。不知道为什么,因为我没有在配置文件中的任何地方显式使用它,所以我遵循了您提供的第二个链接(HtmlWebpackPlugin)。但是我发现,
commonConfig
不是一个函数。
module.exports
应该是函数吗?它不应该是函数,但我可以是函数。这是你需要文件时得到的。在回购协议中,它是一个函数,因此您可以传递选项,如第43行所示。我现在看到与引导加载程序相关的错误。不知道为什么,因为我没有在配置文件的任何地方显式使用它