2024-01-09 00:31:06 +01:00
|
|
|
import { defineConfig } from "vite"
|
|
|
|
import { fileURLToPath, URL } from "url"
|
|
|
|
import postcss from "./postcss.config.js"
|
|
|
|
import react from "@vitejs/plugin-react"
|
|
|
|
import dns from "dns"
|
|
|
|
import { visualizer } from "rollup-plugin-visualizer"
|
2023-06-04 04:28:07 +02:00
|
|
|
|
2024-01-09 00:31:06 +01:00
|
|
|
dns.setDefaultResultOrder("verbatim")
|
2023-06-04 04:28:07 +02:00
|
|
|
|
|
|
|
// https://vitejs.dev/config/
|
|
|
|
export default defineConfig({
|
|
|
|
server: {
|
|
|
|
port: 3000,
|
2024-01-09 00:31:06 +01:00
|
|
|
host: "localhost"
|
2023-06-04 04:28:07 +02:00
|
|
|
},
|
|
|
|
define: {
|
2024-01-09 00:31:06 +01:00
|
|
|
"process.env": process.env
|
2023-06-04 04:28:07 +02:00
|
|
|
},
|
|
|
|
css: {
|
2024-01-09 00:31:06 +01:00
|
|
|
postcss
|
2023-06-04 04:28:07 +02:00
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
react(),
|
|
|
|
visualizer({
|
|
|
|
template: "treemap", // or sunburst
|
|
|
|
open: false,
|
|
|
|
gzipSize: true,
|
|
|
|
brotliSize: true,
|
2024-01-09 00:31:06 +01:00
|
|
|
filename: "bundleinspector.html" // will be saved in project's root
|
|
|
|
})
|
2023-06-04 04:28:07 +02:00
|
|
|
],
|
|
|
|
resolve: {
|
|
|
|
alias: [
|
2024-01-09 00:31:06 +01:00
|
|
|
{
|
|
|
|
find: "@",
|
|
|
|
replacement: fileURLToPath(new URL("./src", import.meta.url))
|
|
|
|
},
|
2023-06-04 04:28:07 +02:00
|
|
|
{
|
|
|
|
process: "process/browser",
|
|
|
|
stream: "stream-browserify",
|
|
|
|
zlib: "browserify-zlib",
|
|
|
|
util: "util",
|
|
|
|
find: /^~.+/,
|
|
|
|
replacement: (val) => {
|
2024-01-09 00:31:06 +01:00
|
|
|
return val.replace(/^~/, "")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2023-06-04 04:28:07 +02:00
|
|
|
},
|
|
|
|
build: {
|
2024-02-07 22:36:20 +01:00
|
|
|
rollupOptions: {
|
|
|
|
external: [
|
|
|
|
// Reduces transformation time by 50% and we don't even use this variant, so we can ignore.
|
|
|
|
/@phosphor-icons\/react\/dist\/ssr/,
|
|
|
|
]
|
|
|
|
},
|
2023-06-04 04:28:07 +02:00
|
|
|
commonjsOptions: {
|
2024-01-09 00:31:06 +01:00
|
|
|
transformMixedEsModules: true
|
2023-06-04 04:28:07 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
optimizeDeps: {
|
|
|
|
esbuildOptions: {
|
|
|
|
define: {
|
2024-01-09 00:31:06 +01:00
|
|
|
global: "globalThis"
|
2023-06-04 04:28:07 +02:00
|
|
|
},
|
2024-01-09 00:31:06 +01:00
|
|
|
plugins: []
|
2023-06-04 04:28:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|