3

我已将 webpack 包更新到最新版本 2.3.2,并且我正在使用 Angular V4.0.0、typescript V2.2.2。运行“npm run build”命令时抛出以下错误。并且它在更新后对 angular2 工作正常,它抛出了错误

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration has an unknown property 'htmlLoader'. 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: {
           htmlLoader: ...
         }
       })
     ]
4

1 回答 1

2

你应该移动 html 加载器

 htmlLoader: {
        minimize: false
    },


plugins: [
  new webpack.LoaderOptionsPlugin({
    options: {
      htmlLoader: {
       minimize: true
      }
    }
  })
]

看看这个链接

在 webpack 2.0 中,他们已经停止支持直接加载自定义加载器。

于 2017-03-31T08:27:31.243 回答