-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.mjs
More file actions
48 lines (41 loc) · 1.44 KB
/
build.mjs
File metadata and controls
48 lines (41 loc) · 1.44 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
import { build } from 'vite';
import vue from '@vitejs/plugin-vue';
import { fileURLToPath } from 'url';
import { dirname, resolve } from 'path';
// Эмулируем __dirname для ES-модулей
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const pages = [
{ name: 'main', html: 'web/index.html' },
{ name: 'graph', html: 'web/graph.html' },
];
async function buildAll() {
let emptyDir = true;
for (const page of pages) {
console.log(`🔨 Building ${page.name}...`);
await build({
root: 'web',
base: '/iframe',
plugins: [vue()],
build: {
outDir: resolve(__dirname, 'iframe'), // теперь __dirname определена
emptyOutDir: emptyDir,
sourcemap: false,
minify: "terser",
terserOptions: { format: { comments: false } },
rollupOptions: {
input: { [page.name]: resolve(__dirname, page.html) },
output: {
entryFileNames: `${page.name}.js`,
chunkFileNames: `${page.name}-[name].js`,
assetFileNames: 'assets/[name].[ext]',
inlineDynamicImports: true,
}
}
}
});
emptyDir = false;
}
console.log('✅ Build complete');
}
buildAll();