在一些的WebPack實例中,你看到提到的 「規則」 陣列:Webpack中的規則vs裝載器 - 有什麼區別?
module.exports = {
module: {
rules: [
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
//resolve-url-loader may be chained before sass-loader if necessary
use: ['css-loader', 'sass-loader']
})
}
]
},
plugins: [
new ExtractTextPlugin('style.css')
//if you want to pass in options, you can do so:
//new ExtractTextPlugin({
// filename: 'style.css'
//})
]
}
(https://github.com/webpack-contrib/extract-text-webpack-plugin)
而在其他中,裝載機數組:
var ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
module: {
loaders: [
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({
loader: "css-loader"
})
},
{ test: /\.png$/, loader: "file-loader" }
]
},
plugins: [
new ExtractTextPlugin({
filename: "style.css",
allChunks: true
})
]
};
(https://github.com/webpack/webpack/tree/master/examples/css-bundle)
有什麼區別?應該使用哪個?
https://webpack.js.org/guides/migrating/#module-loaders-is-now-module-rules – Ivan