Mini-css-giải nén-plugin
Plugin này trích xuất CSS thành các tệp riêng biệt. Nó tạo một tệp CSS trên mỗi tệp JS chứa CSS. Nó hỗ trợ Tải theo yêu cầu của CSS và SourceMaps Show
Nó được xây dựng dựa trên tính năng webpack v5 mới và yêu cầu webpack 5 hoạt động So với extract-text-webpack-plugin
Bắt đầuĐể bắt đầu, bạn cần cài đặt import "./style.css";7 npm install --save-dev mini-css-extract-plugin hoặc yarn add -D mini-css-extract-plugin hoặc pnpm add -D mini-css-extract-plugin Nên kết hợp import "./style.css";7 với import "./style.css";9 Sau đó, thêm trình tải và plugin vào cấu hình const MiniCssExtractPlugin = require("mini-css-extract-plugin"); module.exports = { plugins: [new MiniCssExtractPlugin()], module: { rules: [ { test: /\.css$/i, use: [MiniCssExtractPlugin.loader, "css-loader"], }, ], }, };0 của bạn. Ví dụ Phong cách. css body { background: green; } thành phần. js import "./style.css"; gói web. cấu hình. js const MiniCssExtractPlugin = require("mini-css-extract-plugin"); module.exports = { plugins: [new MiniCssExtractPlugin()], module: { rules: [ { test: /\.css$/i, use: [MiniCssExtractPlugin.loader, "css-loader"], }, ], }, };
Tùy chọnTùy chọn plugin
|