Skip to content

build(sites): optimize build chunks num #2028

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/sites/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"@vue/compiler-sfc": "^3.2.37",
"chalk": "4.1.2",
"cross-spawn": "^7.0.3",
"fast-glob": "^3.2.12",
"fs-extra": "^10.1.0",
"less": "^4.1.3",
"markdown-it": "^13.0.1",
Expand Down
33 changes: 29 additions & 4 deletions examples/sites/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,30 @@ import vue3SvgPlugin from 'vite-svg-loader'
import { getAlias, pathFromWorkspaceRoot, getOptimizeDeps } from '../../internals/cli/src/config/vite'
import virtualTemplatePlugin from '@opentiny-internal/unplugin-virtual-template/vite'
import tailwindCss from 'tailwindcss'
import fg from 'fast-glob'
import fs from 'fs-extra'

const delStatic = () => {
let config
return {
name: 'inline-plugin-del-static',
apply: 'build',
configResolved(_config) {
config = _config
},
async closeBundle() {
const targetPath = path.join(config.build.outDir, '@demos')
const files = await fg(['**/*.spec.js', '**/*.spec.ts'], {
dot: true,
cwd: targetPath
})
files.forEach((filename) => {
const filePath = path.join(targetPath, filename)
fs.unlink(filePath)
})
}
}
}

export default defineConfig((config) => {
const env = loadEnv(config.mode, process.cwd() + '/env', '')
Expand All @@ -23,17 +47,17 @@ export default defineConfig((config) => {
const menuPath = isSaas ? path.resolve('./demos/saas') : path.resolve(demosPath)
const copyTarget = [
{
src: `${demosPath}/**`,
src: `${demosPath}/*`,
dest: '@demos'
},
{
src: `${apisPath}/**`,
src: `${apisPath}/*`,
dest: '@demos/apis'
}
]
if (isSaas) {
copyTarget.push({
src: `./demos/mobile-first/**`,
src: `./demos/mobile-first/*`,
dest: '@demos/mobile-first'
})
}
Expand Down Expand Up @@ -75,7 +99,8 @@ export default defineConfig((config) => {
Unocss(UnoCssConfig),
viteStaticCopy({
targets: copyTarget
})
}),
delStatic()
],
optimizeDeps: getOptimizeDeps(3),
build: {
Expand Down
Loading