Repository navigation
Expand file tree
/
Copy pathvite.config.mts
More file actions
112 lines (110 loc) · 3.12 KB
/
Copy pathvite.config.mts
File metadata and controls
112 lines (110 loc) · 3.12 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
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
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import externalGlobals from 'rollup-plugin-external-globals';
import createExternal from 'vite-plugin-external';
import basicSsl from '@vitejs/plugin-basic-ssl';
import path from 'path';
import { chunkFromId, ViteSpaDev } from './vite-spa-dev';
import tailwindcss from '@tailwindcss/vite';
const HMR_UPDATE_TOPIC = 'hmr-update';
export default defineConfig(({ mode }) => {
const isProd = mode !== 'development';
return {
plugins: [
react(),
tailwindcss(),
basicSsl({
name: 'devkit-ssl',
domains: ['localhost'],
certDir: path.resolve(__dirname, '.devcontainer/ssl'),
}),
createExternal({
externals: {
react: 'React',
'react-dom/client': 'ReactDOM',
'@akashaorg/core-sdk': '"@akashaorg/core-sdk"',
'@akashaorg/ui-core-hooks': '"@akashaorg/ui-core-hooks"',
},
}),
...(isProd
? []
: [
ViteSpaDev({
targetFilePath: 'components/index.tsx',
server: {
port: 8070,
https: true,
host: '0.0.0.0',
hmrTopic: HMR_UPDATE_TOPIC,
},
}),
]),
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
envPrefix: ['PUBLIC_', 'NODE_'],
define: {
__DEV__: !isProd,
},
build: {
modulePreload: true,
target: 'esnext',
rollupOptions: {
input: 'src/index.tsx',
preserveEntrySignatures: 'strict',
external: ['@akashaorg/core-sdk', '@akashaorg/ui-core-hooks', 'react', 'react-dom'],
jsx: 'react-jsx',
plugins: [
externalGlobals({
react: 'React',
'react-dom': 'ReactDOM',
}),
],
output: {
dir: 'dist',
format: 'systemjs',
entryFileNames: 'index.js',
chunkFileNames: chunkInfo => {
if (chunkInfo.name === 'vendor') {
return 'vendor.js';
}
return `${chunkInfo.name}.js`;
},
inlineDynamicImports: false,
experimentalMinChunkSize: Infinity,
systemNullSetters: true,
manualChunks: id => {
if (id.includes('src') && !id.includes('/node_modules/')) {
return chunkFromId(id);
}
return 'vendor';
},
globals: {
react: 'React',
'react-dom': 'ReactDOM',
},
},
onwarn: (warning, warn) => {
if (
warning.code === 'INVALID_ANNOTATION' &&
(warning.id?.includes('/node_modules/graphql-scalars/esm/') ||
warning.id?.includes('/node_modules/@akashaorg/ui-core-hooks/lib/generated/apollo'))
) {
return;
}
return warn(warning);
},
},
minify: isProd ? true : false,
emptyOutDir: true,
},
optimizeDeps: {
include: ['@composedb/client'],
},
logLevel: 'info' as const,
clearScreen: true,
};
});