generated from st-ax/preact-ts-offline-first
-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.ts
104 lines (99 loc) · 3.06 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
import preactRefresh from '@prefresh/vite'
import { execSync } from 'child_process'
import nodePolyfills from 'rollup-plugin-polyfill-node'
import { defineConfig } from 'vite'
import { VitePWA } from 'vite-plugin-pwa'
import WindiCSS from 'vite-plugin-windicss'
// import commonjsExternals from "vite-plugin-commonjs-externals"
// import {builtinModules} from 'module'
// import inject from '@rollup/plugin-inject'
// import nodeResolve from '@rollup/plugin-node-resolve'
// import nodePolyfills from 'rollup-plugin-polyfill-node'
let RPC_URL, LCD_URL
try {
RPC_URL = execSync('gp url 26657').toString().trim()
LCD_URL = execSync('gp url 1317').toString().trim()
} catch (e) {
console.log('not in gitpod')
}
const port = RPC_URL ? 443 : 3000
process.env.RPC_URL = RPC_URL ?? 'http://127.0.0.1:26657'
process.env.LCD_URL = LCD_URL ?? 'http://127.0.0.1:1317'
// const RPC_URL = process.env.GITPOD || 'http://127.0.0.1:26657'
// const LCD_URL = process.env.GITPOD || 'http://127.0.0.1:1317'
console.log(port, process.env.RPC_URL, process.env.LCD_URL)
// https://vitejs.dev/config/
export default defineConfig({
// optimizeDeps: {
// exclude: builtinModules,
// // exclude: [
// // 'buffer',
// // // 'bip32','tiny-secp256k1','@keplr-wallet/crypto','@cosmjs/stargate','@keplr-wallet/stores'
// // ],
// },
// build: {
// assetsDir: '.',
// rollupOptions: {
// output: {
// format: 'cjs'
// },
// external: builtinModules
// },
// },
// build: {
// commonjsOptions: {},
// // or empty commonjsOptions: {}
// },
esbuild: {
jsxFactory: 'h',
jsxFragment: 'Fragment',
target: 'esnext',
// define: {
// 'Buffer': 'Buffer'
// }
},
resolve: {
alias: [
{ find: 'react', replacement: 'preact/compat' },
{ find: 'react-dom', replacement: 'preact/compat' },
// Not necessary unless you consume a module using `createClass`
{ find: 'create-react-class', replacement: 'preact-compat/lib/create-react-class' },
// Not necessary unless you consume a module requiring `react-dom-factories`
{ find: 'react-dom-factories', replacement: 'preact-compat/lib/react-dom-factories' },
],
},
plugins: [
nodePolyfills(),
// nodeResolve({
// browser: true,
// preferBuiltins: false,
// }),
// commonjsExternals({
// externals: builtinModules,
// }),
preactRefresh(),
VitePWA(),
WindiCSS({ safelist: 'prose prose-sm m-auto' }),
// inject({ Buffer: ['buffer', 'Buffer'] }),
// inject({
// include: [
// 'node_modules/@ledgerhq/**',
// 'node_modules/@keplr-wallet/**',
// 'node_modules/tiny-secp256k1',
// ],
// modules: { Buffer: ['buffer', 'Buffer'] },
// }),
],
define: {
'process.env': process?.env || {}, // needed in addition to nodePolyfills
// 'RPC_URL': RPC_URL,
// 'LCD_URL': LCD_URL,
// 'globalThis.Buffer': Buffer, // needed in addition to nodePolyfills
// Buffer, // needed in addition to nodePolyfills
},
server: {
hmr: {
port,
},
},
})