-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
116 lines (112 loc) · 3.16 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import { visualizer } from 'rollup-plugin-visualizer';
import { defineConfig, type UserConfig } from 'vite';
import checker from 'vite-plugin-checker';
import path, { join } from 'node:path';
// https://vitejs.dev/config/
export default defineConfig(async ({ mode }): Promise<UserConfig> => {
const config: UserConfig = {
// https://vitejs.dev/config/#server-options
server: {
fs: {
// Allow serving files from one level up to the project root
allow: ['..'],
},
},
resolve: {
alias: [
{
find: /~(.+)/,
replacement: join(process.cwd(), 'node_modules/$1'),
},
],
},
plugins: [
// vite-plugin-checker
// https://github.com/fi3ework/vite-plugin-checker
checker({
typescript: true,
vueTsc: false,
eslint: {
lintCommand: 'eslint', // for example, lint .ts & .tsx
},
}),
],
optimizeDeps: {
// https://github.com/codemirror/dev/issues/608
exclude: ['@codemirror/state'],
},
// Build Options
// https://vitejs.dev/config/#build-options
build: {
lib: {
entry: path.resolve(__dirname, 'src/index.ts'),
name: 'InertiaComposable',
formats: ['es', 'umd'],
fileName: format => `index.${format}.js`,
},
rollupOptions: {
// @ts-ignore
plugins: [
mode === 'analyze'
? // rollup-plugin-visualizer
// https://github.com/btd/rollup-plugin-visualizer
visualizer({
open: true,
filename: 'dist/stats.html',
gzipSize: true,
brotliSize: true,
})
: undefined,
].filter(item => item !== undefined),
external: [
'bootstrap/dist/css/bootstrap.css',
'bootstrap/dist/css/bootstrap.css?raw',
'@codemirror/language',
'@codemirror/state',
'@codemirror/view',
'@lezer/highlight',
],
output: {
exports: 'named',
globals: {
'bootstrap/dist/css/bootstrap.css?raw': 'bootstrap',
'@lezer/highlight': 'highlight',
'@codemirror/language': 'language',
'@codemirror/lint': 'lint',
'@codemirror/state': 'state',
'@codemirror/view': 'view',
},
},
},
target: 'es2022',
/*
// Minify option
// https://vitejs.dev/config/#build-minify
minify: 'terser',
terserOptions: {
ecma: 2020,
parse: {},
compress: { drop_console: true },
mangle: true, // Note `mangle.properties` is `false` by default.
module: true,
output: { comments: true, beautify: false },
},
*/
},
};
/*
// Write meta data.
fs.writeFileSync(
path.resolve(path.join(__dirname, 'src/Meta.ts')),
`import type MetaInterface from '@/interfaces/MetaInterface';
// This file is auto-generated by the build system.
const meta: MetaInterface = {
version: '${require('./package.json').version}',
date: '${new Date().toISOString()}',
};
export default meta;
`
);
*/
return config;
});