更换cocos
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
const fs = require('fs');
|
||||
const gracefulFs = require('graceful-fs');
|
||||
// Windows 上 webpack/terser 并行打开大量文件时会 EMFILE,这里排队重试
|
||||
gracefulFs.gracefulify(fs);
|
||||
|
||||
const defaultsDeep = require('lodash.defaultsdeep');
|
||||
const path = require('path');
|
||||
const zlib = require('zlib');
|
||||
const webpack = require('webpack');
|
||||
|
||||
// Plugins
|
||||
@@ -40,7 +46,6 @@ const htmlWebpackPluginCommon = {
|
||||
|
||||
// When this changes, the path for all JS files will change, bypassing any HTTP caches
|
||||
const CACHE_EPOCH = 'gleba';
|
||||
const fs = require('fs');
|
||||
const base = {
|
||||
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
|
||||
devtool: process.env.SOURCEMAP || (process.env.NODE_ENV === 'production' ? false : 'cheap-module-source-map'),
|
||||
@@ -304,8 +309,10 @@ module.exports = [
|
||||
},
|
||||
mangle: true
|
||||
},
|
||||
parallel: true,
|
||||
cache: true
|
||||
// Windows 上 parallel:true + cache:true 会在
|
||||
// node_modules/.cache/terser-webpack-plugin/tmp 同时打开过多文件,触发 EMFILE
|
||||
parallel: process.platform === 'win32' ? 2 : true,
|
||||
cache: process.platform !== 'win32'
|
||||
})
|
||||
],
|
||||
splitChunks: {
|
||||
@@ -661,23 +668,31 @@ module.exports = [
|
||||
}
|
||||
]
|
||||
}),
|
||||
// Brotli压缩(比gzip更高效)
|
||||
// 预压缩 JS/CSS/HTML。不要压 SVG:static/images 里有约 19MB 的
|
||||
// about-illustration.svg,gzip level 9 + brotli 会让进度长时间停在
|
||||
// 95% emitting CompressionPlugin,VSCode 终端看起来像卡死。
|
||||
new CompressionPlugin({
|
||||
algorithm: 'brotliCompress',
|
||||
test: /\.(js|css|html|svg|json)$/,
|
||||
threshold: 8192, // 只压缩>8KB的文件
|
||||
test: /\.(js|css|html)$/,
|
||||
exclude: /[\\/]unity[\\/]/,
|
||||
threshold: 8192,
|
||||
minRatio: 0.8,
|
||||
filename: '[path][base].br'
|
||||
filename: '[path][base].br',
|
||||
compressionOptions: {
|
||||
params: {
|
||||
[zlib.constants.BROTLI_PARAM_QUALITY]: 5
|
||||
}
|
||||
}
|
||||
}),
|
||||
// 可选:gzip作为后备
|
||||
new CompressionPlugin({
|
||||
filename: '[path][base].gz',
|
||||
algorithm: 'gzip',
|
||||
test: /\.(js|css|html|svg|json)$/,
|
||||
test: /\.(js|css|html)$/,
|
||||
exclude: /[\\/]unity[\\/]/,
|
||||
threshold: 8192,
|
||||
minRatio: 0.8,
|
||||
compressionOptions: {
|
||||
level: 9
|
||||
level: 6
|
||||
}
|
||||
}),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user