在 dist 文件夹中生成 bundle.css 但它没有被缩小。我手动将它们加载到我的 html 文件中,如下所示<link rel="stylesheet" href="../static/dist/bundle.css">
:还像这样在 index.js 中导入样式文件:import "../css/style.css";
。我如何让这个缩小?
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
mode: "development",
entry: ["./static/js/index.js"],
output: {
path: path.resolve(__dirname, "static/dist"),
filename: "bundle.js"
},
watch: true,
module: {
rules: [
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', "@babel/preset-react"],
plugins: [
['@babel/plugin-proposal-object-rest-spread'],
['@babel/plugin-proposal-class-properties']
]
}
}
},
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
},
'css-loader'
]
}
]
},
plugins: [
new MiniCssExtractPlugin({
filename: "./bundle.css",
}),
]
}