-
Notifications
You must be signed in to change notification settings - Fork 6
/
vite.config.ts
96 lines (94 loc) · 2.53 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/// <reference types="vitest" />
import { defineConfig, loadEnv } from 'vite';
import eslintPlugin from 'vite-plugin-eslint';
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
import VitePluginBrowserSync from 'vite-plugin-browser-sync';
import { chunkSplitPlugin } from 'vite-plugin-chunk-split';
import path from 'path';
export default ({ mode }: { mode: string }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
return defineConfig({
publicDir: path.resolve(__dirname, './src/public'),
root: path.resolve(__dirname, './src'),
base: process.env.NODE_ENV === 'production' ? `${process.env.VITE_THEME_PATH}/dist/` : '/',
build: {
outDir: path.resolve(__dirname, 'dist'),
emptyOutDir: true,
manifest: true,
// minify: false,
sourcemap: process.env.NODE_ENV === 'production' ? false : 'inline',
target: 'es2018',
rollupOptions: {
input: {
app: '/js/app.ts',
admin: '/js/admin.ts',
},
external: ['jquery'],
output: {
globals: {
jquery: 'jQuery',
},
},
},
},
plugins: [
eslintPlugin(),
chunkSplitPlugin({
strategy: 'unbundle',
customChunk: (args) => {
const { id } = args;
if (id.includes('node_modules')) {
return id.toString().split('node_modules/')[1].split('/')[0].toString();
}
return null;
},
}),
VitePluginBrowserSync({
bs: {
online: true,
notify: false,
proxy: {
target: process.env.VITE_ASSET_URL,
ws: true,
proxyReq: [
(proxyReq) => {
proxyReq.setHeader('Browser-Sync', true);
},
],
},
},
}),
createSvgIconsPlugin({
iconDirs: [path.resolve(process.cwd(), 'src/sprite')],
symbolId: 'icon-[name]',
customDomId: 'tofino-sprite',
}),
],
define: { __VUE_PROD_DEVTOOLS__: false },
test: {
include: [`${__dirname}/src/js/tests/*.ts`],
globals: true,
watch: false,
environment: 'jsdom',
coverage: {
provider: 'istanbul',
},
},
server: {
host: true,
cors: true,
strictPort: true,
port: 3000,
hmr: {
port: 3000,
protocol: 'ws',
},
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
vue: 'vue/dist/vue.esm-bundler.js',
},
},
});
};