diff --git a/playground/spa/public/js/haha.bdaaba63.js b/playground/spa/public/js/haha.bdaaba63.js new file mode 100644 index 0000000..351d836 --- /dev/null +++ b/playground/spa/public/js/haha.bdaaba63.js @@ -0,0 +1 @@ +(()=>{var o={hello:"world"};console.log("custom define!");console.log(o);})(); diff --git a/playground/spa/public/js/index.93041bfa.js b/playground/spa/public/js/index.93041bfa.js new file mode 100644 index 0000000..b177f4b --- /dev/null +++ b/playground/spa/public/js/index.93041bfa.js @@ -0,0 +1 @@ +(()=>{var e={VITE_HAHAH:"hahaha",BASE_URL:"/",MODE:"development",DEV:!0,PROD:!1};console.log(e,"env");})(); diff --git a/playground/spa/public/js/test.b7d6e86f.js b/playground/spa/public/js/test.b7d6e86f.js new file mode 100644 index 0000000..6d6a26d --- /dev/null +++ b/playground/spa/public/js/test.b7d6e86f.js @@ -0,0 +1 @@ +(()=>{console.log("this is test");})(); diff --git a/playground/spa/publicTypescript/manifest.json b/playground/spa/publicTypescript/manifest.json index 106fb03..dbd5b8a 100644 --- a/playground/spa/publicTypescript/manifest.json +++ b/playground/spa/publicTypescript/manifest.json @@ -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" } diff --git a/playground/spa/vite.config.ts b/playground/spa/vite.config.ts index 19fd992..09ae6f0 100644 --- a/playground/spa/vite.config.ts +++ b/playground/spa/vite.config.ts @@ -18,7 +18,7 @@ export default defineConfig({ inputDir: 'publicTypescript', manifestName: 'manifest', hash: true, - outputDir: '/', + outputDir: 'js', }), { diff --git a/src/utils/build.ts b/src/utils/build.ts index 4ed00aa..ca84879 100644 --- a/src/utils/build.ts +++ b/src/utils/build.ts @@ -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)