2021-11-17 19:04:16 +01:00
|
|
|
import { svelte } from "@sveltejs/vite-plugin-svelte"
|
2021-03-31 17:14:56 +02:00
|
|
|
import replace from "@rollup/plugin-replace"
|
2022-08-16 11:26:23 +02:00
|
|
|
import { defineConfig, loadEnv } from "vite"
|
2023-06-14 15:54:27 +02:00
|
|
|
import { viteStaticCopy } from "vite-plugin-static-copy"
|
2021-03-31 17:14:56 +02:00
|
|
|
import path from "path"
|
|
|
|
|
2023-01-31 20:34:32 +01:00
|
|
|
const ignoredWarnings = [
|
|
|
|
"unused-export-let",
|
|
|
|
"css-unused-selector",
|
|
|
|
"module-script-reactive-declaration",
|
|
|
|
"a11y-no-onchange",
|
|
|
|
"a11y-click-events-have-key-events",
|
|
|
|
]
|
|
|
|
|
2022-08-16 11:26:23 +02:00
|
|
|
export default defineConfig(({ mode }) => {
|
2021-03-31 17:14:56 +02:00
|
|
|
const isProduction = mode === "production"
|
2022-08-16 11:26:23 +02:00
|
|
|
const env = loadEnv(mode, process.cwd())
|
2021-03-31 17:14:56 +02:00
|
|
|
return {
|
2023-04-18 15:37:29 +02:00
|
|
|
test: {
|
|
|
|
setupFiles: ["./vitest.setup.js"],
|
|
|
|
globals: true,
|
|
|
|
environment: "jsdom",
|
|
|
|
},
|
2021-11-17 20:12:54 +01:00
|
|
|
server: {
|
|
|
|
fs: {
|
|
|
|
strict: false,
|
|
|
|
},
|
2022-08-16 11:26:23 +02:00
|
|
|
hmr: {
|
2022-08-17 10:21:36 +02:00
|
|
|
protocol: env.VITE_HMR_PROTOCOL || "ws",
|
2022-08-16 11:26:23 +02:00
|
|
|
clientPort: env.VITE_HMR_CLIENT_PORT || 3000,
|
2022-08-16 17:27:03 +02:00
|
|
|
path: env.VITE_HMR_PATH || "/",
|
|
|
|
},
|
2022-08-19 12:49:11 +02:00
|
|
|
port: 3000,
|
2021-11-17 20:12:54 +01:00
|
|
|
},
|
2021-05-07 09:17:21 +02:00
|
|
|
base: "/builder/",
|
2021-03-31 17:14:56 +02:00
|
|
|
build: {
|
|
|
|
minify: isProduction,
|
2021-03-31 20:58:30 +02:00
|
|
|
outDir: "../server/builder",
|
2022-02-15 10:23:51 +01:00
|
|
|
sourcemap: !isProduction,
|
2021-03-31 17:14:56 +02:00
|
|
|
},
|
|
|
|
plugins: [
|
2021-03-31 20:12:28 +02:00
|
|
|
svelte({
|
|
|
|
hot: !isProduction,
|
|
|
|
emitCss: true,
|
2023-01-31 20:34:32 +01:00
|
|
|
onwarn: (warning, handler) => {
|
|
|
|
// Ignore some warnings
|
|
|
|
if (!ignoredWarnings.includes(warning.code)) {
|
|
|
|
handler(warning)
|
|
|
|
}
|
|
|
|
},
|
2021-03-31 20:12:28 +02:00
|
|
|
}),
|
2021-03-31 17:14:56 +02:00
|
|
|
replace({
|
|
|
|
preventAssignment: true,
|
|
|
|
"process.env.NODE_ENV": JSON.stringify(
|
|
|
|
isProduction ? "production" : "development"
|
|
|
|
),
|
|
|
|
"process.env.POSTHOG_TOKEN": JSON.stringify(process.env.POSTHOG_TOKEN),
|
2021-09-21 12:47:14 +02:00
|
|
|
"process.env.INTERCOM_TOKEN": JSON.stringify(
|
|
|
|
process.env.INTERCOM_TOKEN
|
|
|
|
),
|
2021-03-31 17:14:56 +02:00
|
|
|
"process.env.SENTRY_DSN": JSON.stringify(process.env.SENTRY_DSN),
|
|
|
|
}),
|
2023-06-14 15:54:27 +02:00
|
|
|
viteStaticCopy({
|
|
|
|
targets: [
|
|
|
|
{
|
|
|
|
src: "../../node_modules/@fontsource/source-sans-pro",
|
2023-06-14 16:12:39 +02:00
|
|
|
dest: "fonts",
|
2023-06-14 15:54:27 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
src: "../../node_modules/remixicon/fonts/*",
|
|
|
|
dest: "fonts",
|
2023-06-14 16:12:39 +02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
}),
|
2021-03-31 17:14:56 +02:00
|
|
|
],
|
|
|
|
optimizeDeps: {
|
|
|
|
exclude: ["@roxi/routify"],
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
dedupe: ["@roxi/routify"],
|
|
|
|
alias: [
|
2021-05-24 17:19:29 +02:00
|
|
|
{
|
|
|
|
find: "assets",
|
|
|
|
replacement: path.resolve("./assets"),
|
|
|
|
},
|
2021-03-31 17:14:56 +02:00
|
|
|
{
|
|
|
|
find: "components",
|
|
|
|
replacement: path.resolve("./src/components"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
find: "builderStore",
|
|
|
|
replacement: path.resolve("./src/builderStore"),
|
|
|
|
},
|
2021-04-01 11:29:47 +02:00
|
|
|
{
|
|
|
|
find: "stores",
|
|
|
|
replacement: path.resolve("./src/stores"),
|
|
|
|
},
|
2022-01-20 19:42:30 +01:00
|
|
|
{
|
|
|
|
find: "api",
|
2022-01-24 17:38:36 +01:00
|
|
|
replacement: path.resolve("./src/api.js"),
|
2022-01-20 19:42:30 +01:00
|
|
|
},
|
2021-03-31 17:14:56 +02:00
|
|
|
{
|
|
|
|
find: "constants",
|
|
|
|
replacement: path.resolve("./src/constants"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
find: "analytics",
|
|
|
|
replacement: path.resolve("./src/analytics"),
|
|
|
|
},
|
2021-05-06 14:58:42 +02:00
|
|
|
{
|
|
|
|
find: "actions",
|
|
|
|
replacement: path.resolve("./src/actions"),
|
|
|
|
},
|
2021-05-06 17:39:34 +02:00
|
|
|
{
|
|
|
|
find: "helpers",
|
|
|
|
replacement: path.resolve("./src/helpers"),
|
|
|
|
},
|
2021-03-31 17:14:56 +02:00
|
|
|
],
|
|
|
|
},
|
|
|
|
}
|
2022-08-16 11:26:23 +02:00
|
|
|
})
|