Skip to content

Commit e6e72c7

Browse files
authored
build(sites): optimize build chunks num (#2028)
1 parent 6d628fe commit e6e72c7

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

examples/sites/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"@vue/compiler-sfc": "^3.2.37",
5959
"chalk": "4.1.2",
6060
"cross-spawn": "^7.0.3",
61+
"fast-glob": "^3.2.12",
6162
"fs-extra": "^10.1.0",
6263
"less": "^4.1.3",
6364
"markdown-it": "^13.0.1",

examples/sites/vite.config.ts

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,30 @@ import vue3SvgPlugin from 'vite-svg-loader'
1313
import { getAlias, pathFromWorkspaceRoot, getOptimizeDeps } from '../../internals/cli/src/config/vite'
1414
import virtualTemplatePlugin from '@opentiny-internal/unplugin-virtual-template/vite'
1515
import tailwindCss from 'tailwindcss'
16+
import fg from 'fast-glob'
17+
import fs from 'fs-extra'
18+
19+
const delStatic = () => {
20+
let config
21+
return {
22+
name: 'inline-plugin-del-static',
23+
apply: 'build',
24+
configResolved(_config) {
25+
config = _config
26+
},
27+
async closeBundle() {
28+
const targetPath = path.join(config.build.outDir, '@demos')
29+
const files = await fg(['**/*.spec.js', '**/*.spec.ts'], {
30+
dot: true,
31+
cwd: targetPath
32+
})
33+
files.forEach((filename) => {
34+
const filePath = path.join(targetPath, filename)
35+
fs.unlink(filePath)
36+
})
37+
}
38+
}
39+
}
1640

1741
export default defineConfig((config) => {
1842
const env = loadEnv(config.mode, process.cwd() + '/env', '')
@@ -23,17 +47,17 @@ export default defineConfig((config) => {
2347
const menuPath = isSaas ? path.resolve('./demos/saas') : path.resolve(demosPath)
2448
const copyTarget = [
2549
{
26-
src: `${demosPath}/**`,
50+
src: `${demosPath}/*`,
2751
dest: '@demos'
2852
},
2953
{
30-
src: `${apisPath}/**`,
54+
src: `${apisPath}/*`,
3155
dest: '@demos/apis'
3256
}
3357
]
3458
if (isSaas) {
3559
copyTarget.push({
36-
src: `./demos/mobile-first/**`,
60+
src: `./demos/mobile-first/*`,
3761
dest: '@demos/mobile-first'
3862
})
3963
}
@@ -75,7 +99,8 @@ export default defineConfig((config) => {
7599
Unocss(UnoCssConfig),
76100
viteStaticCopy({
77101
targets: copyTarget
78-
})
102+
}),
103+
delStatic()
79104
],
80105
optimizeDeps: getOptimizeDeps(3),
81106
build: {

0 commit comments

Comments
 (0)