-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathvite.config.mjs
More file actions
58 lines (49 loc) · 1.6 KB
/
vite.config.mjs
File metadata and controls
58 lines (49 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { cpSync } from 'node:fs';
import { resolve } from 'node:path';
import { defineConfig } from 'vite';
function copyLegacyAssets() {
return {
name: 'copy-legacy-assets',
apply: 'build',
closeBundle() {
const rootDir = resolve(__dirname, 'celstomp');
const outDir = resolve(rootDir, 'dist');
const copyDir = (src, dest) => {
cpSync(resolve(rootDir, src), resolve(outDir, dest), {
recursive: true,
force: true,
});
};
const copyFile = (src, dest) => {
cpSync(resolve(rootDir, src), resolve(outDir, dest), {
force: true,
});
};
// These are loaded dynamically at runtime by celstomp/js/html-loader.js.
copyDir('js', 'js');
copyDir('parts', 'parts');
// Keep existing relative asset paths working in the built output.
copyDir('css', 'css');
copyDir('icons', 'icons');
// Runtime-fetched / not directly referenced by index.html
copyFile('service-worker.js', 'service-worker.js');
// Misc static assets
copyFile('manifest.webmanifest', 'manifest.webmanifest');
copyFile('robots.txt', 'robots.txt');
copyFile('sitemap.xml', 'sitemap.xml');
// Legacy app scripts living at the celstomp/ root
copyFile('celstomp-app.js', 'celstomp-app.js');
copyFile('celstomp-autosave.js', 'celstomp-autosave.js');
copyFile('celstomp-imgseq.js', 'celstomp-imgseq.js');
},
};
}
export default defineConfig({
root: 'celstomp',
base: './',
build: {
outDir: 'dist',
emptyOutDir: true,
},
plugins: [copyLegacyAssets()],
});