-
-
Notifications
You must be signed in to change notification settings - Fork 59
/
vite-base.config.ts
84 lines (80 loc) · 2.01 KB
/
vite-base.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
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import wasm from 'vite-plugin-wasm'
import topLevelAwait from 'vite-plugin-top-level-await'
import path from 'path'
import autoprefixer from 'autoprefixer'
import inject from '@rollup/plugin-inject'
import commonjs from '@rollup/plugin-commonjs'
import { deferScripsPlugin } from './vite-config/plugins/deferScriptsPlugin'
import { preloadCSSPlugin } from './vite-config/plugins/preloadCSSPlugin'
import { excludeBip39Wordlists } from './vite-config/rollup/excludeBip39Wordlists'
export default defineConfig({
plugins: [
wasm(),
topLevelAwait(),
vue(),
commonjs(),
inject({
Buffer: ['buffer', 'Buffer']
}),
deferScripsPlugin(),
preloadCSSPlugin()
],
css: {
postcss: {
plugins: [autoprefixer()]
},
preprocessorOptions: {
scss: {
includePaths: ['./src']
}
}
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
// Node.js polyfills
buffer: 'buffer/',
events: 'rollup-plugin-node-polyfills/polyfills/events',
stream: 'stream-browserify',
path: 'path-browserify',
crypto: 'crypto-browserify',
http: 'stream-http',
https: 'https-browserify',
os: 'os-browserify/browser',
assert: 'assert'
},
extensions: ['.ts', '.js', '.json', '.vue']
},
server: {
port: 8080
},
define: {
'process.env': {} // some old libs like `promise-queue` still uses Webpack
},
optimizeDeps: {
esbuildOptions: {
// Node.js global to browser globalThis
define: {
global: 'globalThis'
}
}
},
build: {
commonjsOptions: {
include: []
},
rollupOptions: {
external: [...excludeBip39Wordlists()],
output: {
assetFileNames: (assetInfo) => {
if (assetInfo.name.startsWith('materialdesignicons-webfont')) {
return 'assets/[name][extname]'
}
return 'assets/[name]-[hash][extname]'
}
}
}
}
})