-
-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathvite.config.ts
More file actions
79 lines (68 loc) · 1.96 KB
/
Copy pathvite.config.ts
File metadata and controls
79 lines (68 loc) · 1.96 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import * as path from 'path';
import * as fs from 'fs';
import type { ResolvedConfig } from 'vite';
import { defineConfig, mergeConfig } from 'vite';
import banner from 'vite-plugin-banner';
import { viteStaticCopy } from 'vite-plugin-static-copy';
import versioner from './version';
const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
const now = new Date();
const dt = now.getFullYear() + '-' + (now.getMonth() + 1) + '-' + now.getDate();
const version = process.env.release ? versioner.getReleaseVersion() : versioner.getAlphaVersion();
import commonConfig from './vite.config.common';
export default defineConfig(({ mode }) => {
let config: ResolvedConfig;
// eslint-disable-next-line no-console
console.log(`[version] ${version}.js`);
return mergeConfig(commonConfig, {
build: {
target: 'es2018',
outDir: path.resolve(__dirname, 'build'),
emptyOutDir: false,
lib: {
formats: ['es', 'umd'],
name: 'ex',
fileName(format) {
let fileName = 'excalibur';
if (config.build.minify) {
fileName += '.min';
}
if (mode === 'development') {
fileName += '.development';
}
if (format === 'es') {
return `esm/${fileName}.js`;
}
return `dist/${fileName}.js`;
},
entry: 'src/engine/index.ts'
}
},
plugins: [
// get the resolved vite config so we can reference it in
// callbacks
{
name: 'get-config',
configResolved(v) {
config = v;
}
},
viteStaticCopy({
targets: [
{
src: 'src/engine/excalibur.d.ts',
dest: 'dist/',
rename: { stripBase: true }
}
]
}),
banner(
`${pkg.name} - ${version} - ${dt}
${pkg.homepage}
Copyright (c) ${now.getFullYear()} Excalibur.js <${pkg.author}>
Licensed ${pkg.license}
@preserve`
)
]
});
});