Files
radicle-explorer/vite.config.ts
T
Sebastian Martinez f38893407a Add hash routing
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2022-11-15 15:24:12 +01:00

59 lines
1.4 KiB
TypeScript

///<reference types="vitest" />
import type { UserConfig } from "vite";
import path from "path";
import pluginRewriteAll from "vite-plugin-rewrite-all";
import { svelte } from "@sveltejs/vite-plugin-svelte";
const config: UserConfig = {
optimizeDeps: {
exclude: ["@pedrouid/environment", "@pedrouid/iso-crypto"],
},
test: {
deps: {
inline: ["@ethersproject/signing-key", "@ethersproject/basex"],
},
environment: "happy-dom",
include: ["**/*.test.ts"],
reporters: "verbose",
},
plugins: [
svelte({
hot: !process.env.VITEST,
compilerOptions: {
dev: process.env.NODE_ENV !== "production",
},
}),
pluginRewriteAll(),
],
server: {
// We have to set host here, otherwise CI binds to the ipv6 address and
// e2e tests don't work.
host: "127.0.0.1",
port: 3000,
},
resolve: {
alias: {
"@public": path.resolve("./public"),
"@app": path.resolve("./src"),
},
},
define: {
"process.env": {
// eslint-disable-next-line @typescript-eslint/naming-convention
READABLE_STREAM: "disable",
hashRouting: Boolean(process.env.HASH_ROUTING),
},
},
build: {
outDir: "build",
sourcemap: true,
},
};
// For Vitest to work we need to unset READABLE_STREAM.
if (process.env.VITEST || process.env.Cypress) {
config.define = undefined;
}
export default config;