Skip to content

Commit

Permalink
refactor: migrate vite client bundle files directory (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexzhang1030 authored Mar 4, 2024
1 parent 6b43083 commit 34f220d
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ packages/browser-extension/overlay/**/*
packages/browser-extension/client/**/*
packages/electron/client/**/*
packages/vite/src/overlay/**/*
packages/vite/client/**/*
docs/.vitepress/cache/

# for scripts
Expand Down
3 changes: 2 additions & 1 deletion packages/client/scripts/pre-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import fse from 'fs-extra'
const __dirname = fileURLToPath(new URL('.', import.meta.url))

async function run() {
;['../../browser-extension/client', '../../electron/client', '../../vite/dist/client'].forEach((dir) => {
;['../../browser-extension/client', '../../electron/client', '../../vite/client'].forEach((dir) => {
const absoluteDir = resolve(__dirname, dir)
if (fse.existsSync(absoluteDir))
fse.removeSync(absoluteDir)
})
console.log('🎉 Pre-build: removed client bundles successfully.\n')
}

await run()
2 changes: 1 addition & 1 deletion packages/client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default defineConfig(mergeConfig(baseConfig, {
// copy
const clientFile = resolve(__dirname, './dist')

;['../browser-extension/client', '../electron/client', '../vite/dist/client'].forEach((dir) => {
;['../browser-extension/client', '../electron/client', '../vite/client'].forEach((dir) => {
fse.copySync(clientFile, resolve(__dirname, dir))
})
},
Expand Down
2 changes: 0 additions & 2 deletions packages/client/vite.lib.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ export default defineConfig(mergeConfig(baseConfig, {
// copy
const clientFile = resolve(__dirname, './dist')
;['../browser-extension/client', '../electron/client'].forEach((dir) => {
// NOTE: remember the order of `build:lib` and `build`,
// if change the order, rmSync must set in `build` stage
fse.copySync(clientFile, resolve(__dirname, dir))
})
},
Expand Down
1 change: 1 addition & 0 deletions packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"*.d.ts",
"./src/overlay.js",
"./src/overlay/**",
"client",
"dist",
"overlay"
],
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/dir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export const DIR_DIST = typeof __dirname !== 'undefined'
? __dirname
: dirname(fileURLToPath(import.meta.url))

export const DIR_CLIENT = resolve(DIR_DIST, '../dist/client')
export const DIR_CLIENT = resolve(DIR_DIST, '../client')

0 comments on commit 34f220d

Please sign in to comment.