Skip to content

Commit

Permalink
fix: ensure output dir
Browse files Browse the repository at this point in the history
  • Loading branch information
hemengke1997 committed Mar 31, 2023
1 parent 22e8a1f commit dc63f66
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions playground/spa/public/js/haha.bdaaba63.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(()=>{var o={hello:"world"};console.log("custom define!");console.log(o);})();
1 change: 1 addition & 0 deletions playground/spa/public/js/index.93041bfa.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(()=>{var e={VITE_HAHAH:"hahaha",BASE_URL:"/",MODE:"development",DEV:!0,PROD:!1};console.log(e,"env");})();
1 change: 1 addition & 0 deletions playground/spa/public/js/test.b7d6e86f.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(()=>{console.log("this is test");})();
6 changes: 3 additions & 3 deletions playground/spa/publicTypescript/manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"haha": "/haha.bdaaba63.js",
"index": "/index.93041bfa.js",
"test": "/test.b7d6e86f.js"
"haha": "js/haha.bdaaba63.js",
"index": "js/index.93041bfa.js",
"test": "js/test.b7d6e86f.js"
}
2 changes: 1 addition & 1 deletion playground/spa/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default defineConfig({
inputDir: 'publicTypescript',
manifestName: 'manifest',
hash: true,
outputDir: '/',
outputDir: 'js',
}),

{
Expand Down
8 changes: 7 additions & 1 deletion src/utils/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,13 @@ export async function deleteOldJsFile(args: IDeleteFile) {
config: { publicDir },
} = getGlobalConfig()

const oldFiles = await glob(normalizePath(path.join(publicDir, `${outputDir}/${fileName}.?(*.)js`)))
let oldFiles: string[] = []
try {
fs.ensureDirSync(path.join(publicDir, outputDir))
oldFiles = await glob(normalizePath(path.join(publicDir, `${outputDir}/${fileName}.?(*.)js`)))
} catch (e) {
console.error(e)
}

debug('deleteOldJsFile - oldFiles:', oldFiles)

Expand Down

0 comments on commit dc63f66

Please sign in to comment.