authelia/web/vite.config.ts
renovate[bot] f02190d89c
build(deps): update dependency vite-tsconfig-paths to v3.3.17 (#2492)
* build(deps): update dependency vite-tsconfig-paths to v3.3.17

* fix(web): remove vite resolve alias workaround

The resolve alias issue with Vite has been resolved in the `vite-tsconfig-paths` plugin.

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Amir Zarrinkafsh <nightah@me.com>
2021-10-12 14:04:30 +11:00

63 lines
1.9 KiB
TypeScript

import reactRefresh from "@vitejs/plugin-react-refresh";
import { defineConfig, loadEnv } from "vite";
import eslintPlugin from "vite-plugin-eslint";
import istanbul from "vite-plugin-istanbul";
import svgr from "vite-plugin-svgr";
import tsconfigPaths from "vite-tsconfig-paths";
// @ts-ignore
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, "env");
const isCoverage = process.env.VITE_COVERAGE === "true";
const sourcemap = isCoverage ? "inline" : undefined;
const htmlPlugin = () => {
return {
name: "html-transform",
transformIndexHtml(html: string) {
return html.replace(/%(.*?)%/g, function (match, p1) {
return env[p1];
});
},
};
};
const istanbulPlugin = isCoverage
? istanbul({
include: "src/*",
exclude: ["node_modules"],
extension: [".js", ".jsx", ".ts", ".tsx"],
requireEnv: true,
})
: undefined;
return {
base: "./",
build: {
sourcemap,
outDir: "../internal/server/public_html",
assetsDir: "static",
rollupOptions: {
output: {
entryFileNames: `static/js/[name].[hash].js`,
chunkFileNames: `static/js/[name].[hash].js`,
assetFileNames: ({ name }) => {
if (name && name.endsWith(".css")) {
return "static/css/[name].[hash].[ext]";
}
return "static/media/[name].[hash].[ext]";
},
},
},
},
server: {
open: false,
hmr: {
clientPort: env.VITE_HMR_PORT || 3000,
},
},
plugins: [eslintPlugin(), htmlPlugin(), istanbulPlugin, reactRefresh(), svgr(), tsconfigPaths()],
};
});