不用mini-css-extract-plugin 就处理不了...
npm i -D file-loader
// webpack.config.js
const path = require('path');
const HTMLWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const glob = require('glob-all');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const PurifyCSSPlugin = require('purifycss-webpack');
module.exports = {
entry: {
index: './src/index.js',
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].bundle.js',
},
module: {
rules: [
{
test: /\.css$/,
use: [{ loader: MiniCssExtractPlugin.loader },
{ loader: 'css-loader' },
]
},
{
test: /\.(png|jpg|jpef|gif|)$/,
use: [{
loader:'file-loader',
options: {
outputPath: 'assets/',
useRlativePath: true
}
}]
}
]
},
plugins: [
new HTMLWebpackPlugin({
title: 'css'
}),
new MiniCssExtractPlugin({
filename: "[name].css",
chunkFilename: "[id].css"
}),
],
mode: 'development'
};
// base.css
小于某个大小时转base64编码
$_> npm i -D url-loader
// webpack.config.js
const path = require('path');
const HTMLWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const glob = require('glob-all');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const PurifyCSSPlugin = require('purifycss-webpack');
module.exports = {
entry: {
index: './src/index.js',
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].bundle.js',
},
module: {
rules: [
{
test: /\.css$/,
use: [{ loader: MiniCssExtractPlugin.loader },
{ loader: 'css-loader' },
]
},
{
test: /\.(png|jpg|jpef|gif|)$/,
use: [{
loader:'url-loader',
options: {
limit: 20480,
useRelativePath: true
}
}]
}
]
},
plugins: [
new HTMLWebpackPlugin({
title: 'css'
}),
new MiniCssExtractPlugin({
filename: "[name].css",
chunkFilename: "[id].css"
}),
],
mode: 'development'
};
捕获.JPG
网友评论