我是一个 webpack 菜鸟。看起来vue-loader
还没有用 webpack 2 更新。Webpack 有一个示例帮助器(LoaderOptionsPlugin
),但我根本无法让它工作。这是被抛出的:
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
- configuration has an unknown property 'rules'. 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: {
rules: ...
}
})
]
我的配置:
module.exports = {
entry: './src/main.js',
path: path.resolve(__dirname, 'dist'),
rules: [
{test: /\.vue$/, use: 'vue-loader'},
],
plugins: [
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false,
options: {
context: __dirname
}
})
]
}
我不想仅仅为了完成这项工作而降级 webpack。我在选项中放置什么?我还没有找到任何例子......任何帮助都会很棒。谢谢!