-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
82 lines (77 loc) · 2.61 KB
/
vite.config.ts
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
80
81
82
import { defineConfig, UserConfigFn, UserConfig } from 'vite';
import stripCode from 'rollup-plugin-strip-code';
import { resolve } from 'path';
import { execSync } from 'child_process';
import dts from 'vite-plugin-dts';
import { setDefaultResultOrder } from 'dns'
setDefaultResultOrder('verbatim')
const getConfig: UserConfigFn = ({ mode }) => {
const baseConfig: UserConfig = {
build: {
lib: {
entry: resolve(__dirname, 'src/index.ts'),
name: 'phaser-boilerplate',
formats: ['es'],
fileName: (format) => `phaser-boilerplate.${format}.js`,
},
outDir: 'lib',
},
base: './',
plugins: [
dts({
tsconfigPath: "./tsconfig.json",
copyDtsFiles: true,
include: ["src/**/*"]
}),
],
resolve: {
alias: {
configs: resolve(__dirname, "./src/configs"),
core: resolve(__dirname, "./src/core"),
styles: resolve(__dirname, "./styles"),
assets: resolve(__dirname, "./assets"),
scenes: resolve(__dirname, "./src/scenes"),
entities: resolve(__dirname, "./src/entities"),
components: resolve(__dirname, "./src/components"),
utils: resolve(__dirname, "./src/utils"),
root: resolve(__dirname, "./src"),
},
},
// test: {
// globals: true,
// environment: 'happy-dom',
// coverage: {
// reporter: ['text', 'json', 'html']
// },
// exclude: [
// ...configDefaults.exclude,
// '/test/**/*',
// 'scripts/**/*',
// ],
// },
define: {
'IS_DEV': mode === 'development',
'GAME_VERSION': JSON.stringify(process.env.npm_package_version),
'GAME_BRANCH': JSON.stringify(execSync('git rev-parse --abbrev-ref HEAD').toString().trimEnd()),
'GAME_TIMESTAMP': JSON.stringify(new Date().toLocaleString()),
},
server: {
port: 3000,
proxy: {
},
}
};
if (mode === 'production') {
return Object.assign(baseConfig, {
plugins: [...baseConfig.plugins,
stripCode({
start_comment: 'develblock:start',
end_comment: 'develblock:end',
}),
],
});
}
return baseConfig;
}
// https://vitejs.dev/config/
export default defineConfig(getConfig);