-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
107 lines (104 loc) · 2.81 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
import { defineConfig } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte";
import { windi } from "svelte-windicss-preprocess";
import sveltePreprocess from "svelte-preprocess";
import babel from "@babel/core";
import babelPresetReact from "@babel/preset-react";
import path from "path";
import { nodePolyfills } from "vite-plugin-node-polyfills";
function differMuiSourcemapsPlugins() {
const muiPackages = ["@mui/material", "@emotion/styled", "@emotion/react"];
return {
name: "differ-mui-sourcemap",
transform(code: string, id: string) {
if (muiPackages.some((pkg) => id.includes(pkg))) {
return {
code: code,
map: null,
};
}
},
};
}
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
nodePolyfills({
globals: {
Buffer: true, // can also be 'build', 'dev', or false
global: true,
process: true,
},
}),
svelte({
preprocess: [
sveltePreprocess({
babel: {
babelrc: false,
presets: [
[
babelPresetReact,
{
runtime: "automatic",
},
],
],
},
}),
windi({}),
],
experimental: {
dynamicCompileOptions({ filename, compileOptions }) {
return {
...compileOptions,
customElement: filename.endsWith(".custom.svelte"),
};
},
},
}),
differMuiSourcemapsPlugins(),
],
resolve: {
alias: {
"~": path.resolve(__dirname, "./src"),
"webext-bridge": path.resolve(__dirname, "./src/lib/web-bridge"),
"webextension-polyfill": path.resolve(__dirname, "./src/lib/web-chrome"),
},
},
build: {
target: ["es2020"],
sourcemap: false,
rollupOptions: {
external: ["@ston-fi/sdk", "@wormhole-foundation/wormhole-connect"],
cache: false,
onwarn(warning, warn) {
if (warning.code === "MODULE_LEVEL_DIRECTIVE") {
return;
}
warn(warning);
},
plugins: [
// inject({ Buffer: ["buffer/", "Buffer"] }),
// json(),
// globals(),
// builtins(),
],
output: {
entryFileNames: `assets/[name].js`,
chunkFileNames: `assets/[name].js`,
assetFileNames: `assets/[name].[hash].[ext]`,
globals: {
"@ston-fi/sdk": "@ston-fi/sdk",
"@wormhole-foundation/wormhole-connect":
"@wormhole-foundation/wormhole-connect",
},
},
},
// outDir: path.resolve(__dirname, "web-build"),
// sourcemap: env.WATCH === "true" ? "inline" : false,
},
optimizeDeps: {
include: ["webextension-polyfill"],
exclude: ["@ston-fi/sdk", "@wormhole-foundation/wormhole-connect"],
},
});