0
的差距我是一個webpack noob。它看起來像vue-loader
尚未與webpack 2更新。Webpack有一個例子的幫手(LoaderOptionsPlugin
),但我不能得到它的工作。這就是被拋出:填補與webpack2和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只是爲了使這項工作。我在選項中放置什麼?我還沒有找到任何例子......任何幫助都會很棒。謝謝!