mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-05 19:41:57 +08:00
fix: webpack 缓存不断叠加 (#167)
This commit is contained in:
parent
eee453b601
commit
ab4cc6a5a8
@ -45,8 +45,10 @@
|
||||
"copy-webpack-plugin": "^7.0.0",
|
||||
"css-loader": "^5.0.1",
|
||||
"css-minimizer-webpack-plugin": "^3.0.0",
|
||||
"fs-extra": "^10.0.0",
|
||||
"html-webpack-plugin": "^5.0.0",
|
||||
"html-webpack-tags-plugin": "^3.0.0",
|
||||
"get-folder-size": "^2.0.1",
|
||||
"less": "3.9.0",
|
||||
"less-loader": "^8.0.0",
|
||||
"mini-css-extract-plugin": "^1.3.5",
|
||||
|
@ -1,3 +1,22 @@
|
||||
const path = require('path');
|
||||
|
||||
async function handleCacheClean(cwd) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const cachePath = path.join(cwd, '.cache/webpack');
|
||||
require('get-folder-size')(cachePath, (err, size) => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
// 大于 5G 清除缓存,修复 webpack 缓存无限增长问题
|
||||
// https://github.com/webpack/webpack/issues/13291
|
||||
if (size > 5 * 1024 * 1024 * 1024) {
|
||||
require('fs-extra').removeSync(cachePath);
|
||||
}
|
||||
resolve(size);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export default (api) => {
|
||||
const {
|
||||
paths,
|
||||
@ -28,6 +47,7 @@ export default (api) => {
|
||||
async fn({ args = {} }) {
|
||||
const { cleanTmpPathExceptCache, getBundleAndConfigs } = require('../buildDevUtils');
|
||||
const connectHistoryMiddleware = require('./connectHistoryMiddleware').default;
|
||||
await handleCacheClean(api.paths.cwd);
|
||||
|
||||
port = await getPort(process.env.PORT || args.port || api.config.devServer?.port);
|
||||
|
||||
|
@ -1,31 +1,32 @@
|
||||
import { defineBuildConfig } from '@fesjs/fes'
|
||||
import { defineBuildConfig } from '@fesjs/fes';
|
||||
|
||||
export default defineBuildConfig({
|
||||
define: {
|
||||
__DEV__: false
|
||||
__DEV__: false,
|
||||
},
|
||||
html: {
|
||||
title: '海贼王'
|
||||
title: '海贼王',
|
||||
},
|
||||
router: {
|
||||
mode: 'hash'
|
||||
mode: 'hash',
|
||||
},
|
||||
watermark: {
|
||||
disabled: false
|
||||
disabled: false,
|
||||
},
|
||||
access: {
|
||||
roles: {
|
||||
admin: ['*'],
|
||||
menuTest: ['/', '/menuTest']
|
||||
}
|
||||
menuTest: ['/', '/menuTest'],
|
||||
},
|
||||
},
|
||||
mock: {
|
||||
prefix: '/v2'
|
||||
prefix: '/v2',
|
||||
},
|
||||
proxy: {
|
||||
'/v2': {
|
||||
target: 'https://api.douban.com/',
|
||||
changeOrigin: true
|
||||
}
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
layout: {
|
||||
title: 'Fes.js',
|
||||
@ -37,60 +38,58 @@ export default defineBuildConfig({
|
||||
{
|
||||
name: 'index',
|
||||
icon: '/wine-outline.svg',
|
||||
match: ['/route/*']
|
||||
match: ['/route/*'],
|
||||
},
|
||||
{
|
||||
name: 'store'
|
||||
name: 'store',
|
||||
},
|
||||
{
|
||||
name: 'editor',
|
||||
icon: '/wine-outline.svg'
|
||||
icon: '/wine-outline.svg',
|
||||
},
|
||||
{
|
||||
title: '$externalLink',
|
||||
icon: 'UserOutlined',
|
||||
path: 'https://www.baidu.com'
|
||||
path: 'https://www.baidu.com',
|
||||
},
|
||||
{
|
||||
name: 'mock'
|
||||
name: 'mock',
|
||||
},
|
||||
{
|
||||
title: '菜单权限测试',
|
||||
children: [
|
||||
{
|
||||
title: '子菜单',
|
||||
path: '/menuTest'
|
||||
path: '/menuTest',
|
||||
},
|
||||
]
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'cssModule'
|
||||
name: 'cssModule',
|
||||
},
|
||||
{
|
||||
name: 'pinia'
|
||||
name: 'pinia',
|
||||
},
|
||||
],
|
||||
menuProps: {
|
||||
defaultExpandAll: false
|
||||
}
|
||||
defaultExpandAll: false,
|
||||
},
|
||||
},
|
||||
devServer: {
|
||||
port: 8080
|
||||
port: 8080,
|
||||
},
|
||||
enums: {
|
||||
status: [
|
||||
['0', '无效的'],
|
||||
['1', '有效的']
|
||||
]
|
||||
['1', '有效的'],
|
||||
],
|
||||
},
|
||||
vuex: {
|
||||
strict: true
|
||||
strict: true,
|
||||
},
|
||||
dynamicImport: true,
|
||||
monacoEditor: {
|
||||
languages: ['javascript', 'typescript', 'html', 'json']
|
||||
languages: ['javascript', 'typescript', 'html', 'json'],
|
||||
},
|
||||
presets: [
|
||||
require.resolve('../fes-builder-webpack/lib'),
|
||||
]
|
||||
presets: [require.resolve('../fes-builder-webpack/lib')],
|
||||
});
|
||||
|
18
yarn.lock
18
yarn.lock
@ -6113,6 +6113,11 @@ functions-have-names@^1.2.2:
|
||||
resolved "https://registry.npmmirror.com/functions-have-names/-/functions-have-names-1.2.3.tgz#0404fe4ee2ba2f607f0e0ec3c80bae994133b834"
|
||||
integrity sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==
|
||||
|
||||
gar@^1.0.4:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.npmmirror.com/gar/-/gar-1.0.4.tgz#f777bc7db425c0572fdeb52676172ca1ae9888b8"
|
||||
integrity sha512-w4n9cPWyP7aHxKxYHFQMegj7WIAsL/YX/C4Bs5Rr8s1H9M1rNtRWRsw+ovYMkXDQ5S4ZbYHsHAPmevPjPgw44w==
|
||||
|
||||
gensync@^1.0.0-beta.2:
|
||||
version "1.0.0-beta.2"
|
||||
resolved "https://registry.npmmirror.com/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0"
|
||||
@ -6123,6 +6128,14 @@ get-caller-file@^2.0.1, get-caller-file@^2.0.5:
|
||||
resolved "https://registry.npmmirror.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
|
||||
integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==
|
||||
|
||||
get-folder-size@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.npmmirror.com/get-folder-size/-/get-folder-size-2.0.1.tgz#3fe0524dd3bad05257ef1311331417bcd020a497"
|
||||
integrity sha512-+CEb+GDCM7tkOS2wdMKTn9vU7DgnKUTuDlehkNJKNSovdCOVxs14OfKCk4cvSaR3za4gj+OBdl9opPN9xrJ0zA==
|
||||
dependencies:
|
||||
gar "^1.0.4"
|
||||
tiny-each-async "2.0.3"
|
||||
|
||||
get-intrinsic@^1.0.2, get-intrinsic@^1.1.0, get-intrinsic@^1.1.1, get-intrinsic@^1.1.3:
|
||||
version "1.1.3"
|
||||
resolved "https://registry.npmmirror.com/get-intrinsic/-/get-intrinsic-1.1.3.tgz#063c84329ad93e83893c7f4f243ef63ffa351385"
|
||||
@ -10662,6 +10675,11 @@ thunky@^1.0.2:
|
||||
resolved "https://registry.npmmirror.com/thunky/-/thunky-1.1.0.tgz#5abaf714a9405db0504732bbccd2cedd9ef9537d"
|
||||
integrity sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==
|
||||
|
||||
tiny-each-async@2.0.3:
|
||||
version "2.0.3"
|
||||
resolved "https://registry.npmmirror.com/tiny-each-async/-/tiny-each-async-2.0.3.tgz#8ebbbfd6d6295f1370003fbb37162afe5a0a51d1"
|
||||
integrity sha512-5ROII7nElnAirvFn8g7H7MtpfV1daMcyfTGQwsn/x2VtyV+VPiO5CjReCJtWLvoKTDEDmZocf3cNPraiMnBXLA==
|
||||
|
||||
tmp@^0.0.33:
|
||||
version "0.0.33"
|
||||
resolved "https://registry.npmmirror.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
|
||||
|
Loading…
x
Reference in New Issue
Block a user