-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
49 lines (47 loc) · 1.32 KB
/
vite.config.js
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
import { defineConfig } from 'vite';
import viteBanner from 'vite-plugin-banner';
import { createHtmlPlugin } from 'vite-plugin-html';
import pkg from './package.json';
const banner = `
/**
* @name ${pkg.name}
* @description ${pkg.description}
*
* @version ${pkg.version}
* @author ${pkg.author}
* @license ${pkg.license}
*/
`.trim();
const outputFolder = 'dist'; // Specify the output directory (relative to project root).
const assetsFolder = 'assets'; // Specify the assets folder (relative to project root).
const isForGithub = process.env.BRANCH === 'gh-pages';
export default defineConfig({
base: isForGithub ? '/Ray-Casting/' : '/', // The name of the Github repository
assetsInclude: assetsFolder,
server: {
open: true,
host: true,
},
build: {
outDir: outputFolder,
assetsDir: assetsFolder,
assetsInlineLimit: 0,
minify: 'terser',
emptyOutDir: true,
rollupOptions: {
output: {
dir: outputFolder,
chunkFileNames: '[name].js',
entryFileNames: '[name].js',
assetFileNames: ({ name = '' }) => {
if (/\.css/.test(name)) return `${assetsFolder}/styles/[name][extname]`;
return '[name][extname]';
}
}
}
},
plugins: [
viteBanner({ outDir: outputFolder, content: banner }),
createHtmlPlugin({ minify: true }),
]
});