Webpack版本:4.35.3
所有的编译都是成功的。我的代码在编译后在weble.css中没有缩小。我试图在text-webpack-plugin中使用minimize:true,但它不起作用。
对于编译,我在命令行中使用命令:webpack在我的工作目录中
我做错了什么?为什么MiniCssExtractPlugin不工作,也许是因为resolve-url-loader?
我的wepback配置:
const AssetsWebpackPlugin = require('assets-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const FaviconsWebpackPlugin = require('favicons-webpack-plugin')
const FileManagerPlugin = require('filemanager-webpack-plugin')
const { PATH } = require('../constants')
module.exports = {
mode: 'production',
output: {
path: PATH.publicFolder,
publicPath: '/',
filename: 'static/react/js/[name].[contenthash].js',
chunkFilename: 'static/react/js/[name].[contenthash].js',
sourceMapFilename: 'static/react/js/[name].[contenthash].js.map',
jsonpFunction: 'reactJsonpFunction',
},
performance: {
hints: false,
},
watch: false,
devtool: 'source-map',
plugins: [
new DefinePlugin({
NODE_ENV: JSON.stringify('production'),
}),
new AssetsWebpackPlugin({
filename: 'static/react/assets.json',
path: PATH.publicFolder,
}),
new MiniCssExtractPlugin({
filename: 'static/react/css/common.css',
}),
new FaviconsWebpackPlugin({
logo: PATH.favicon,
prefix: 'static/react/icons/',
emitStats: false,
statsFilename: 'iconstats.json',
background: '#fff',
persistentCache: true,
inject: true,
icons: {
android: true,
appleIcon: true,
appleStartup: true,
coast: false,
favicons: true,
firefox: true,
opengraph: false,
twitter: false,
yandex: false,
windows: false,
},
}),
new FileManagerPlugin({
onStart: {
delete: ['../jrp-web-app/static/react/'],
},
onEnd: {
mkdir: ['../jrp-web-app/static/react/'],
copy: [
{
source: 'public/static/react',
destination: '../jrp-web-app/static/react',
},
],
},
}),
],
module: {
rules: [
{
test: /\.(png|jpg|gif|svg|woff|woff2)$/,
use: [
{
loader: 'file-loader',
options: {
name: 'static/react/images/[name]-[hash:8].[ext]',
},
},
],
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
sourceMap: false,
},
},
'resolve-url-loader',
{
loader: 'postcss-loader',
options: {
sourceMap: false,
config: {
path: PATH.postcssConfig,
},
},
},
],
},
],
},
}```
字符串
1条答案
按热度按时间xurqigkl1#
你有在js文件中使用过cssle.css吗?如果没有,mini-css-extract-plugin会忽略它。