2023-02-16 03:06:44 +00:00
|
|
|
import { defineConfig } from "vite";
|
|
|
|
import react from "@vitejs/plugin-react";
|
2023-03-02 04:07:28 +00:00
|
|
|
import legacy from "@vitejs/plugin-legacy";
|
2021-11-18 01:32:04 +00:00
|
|
|
import tsconfigPaths from "vite-tsconfig-paths";
|
2023-02-16 03:06:44 +00:00
|
|
|
import viteCompression from "vite-plugin-compression";
|
2021-11-18 01:32:04 +00:00
|
|
|
|
2023-04-19 01:59:56 +00:00
|
|
|
const nolegacy = process.env.VITE_APP_NOLEGACY === "true";
|
|
|
|
const sourcemap = process.env.VITE_APP_SOURCEMAPS === "true";
|
|
|
|
|
2021-11-18 01:32:04 +00:00
|
|
|
// https://vitejs.dev/config/
|
2023-04-19 01:59:56 +00:00
|
|
|
export default defineConfig(() => {
|
|
|
|
let plugins = [
|
2023-05-04 03:33:39 +00:00
|
|
|
react({
|
|
|
|
babel: {
|
|
|
|
compact: true,
|
|
|
|
},
|
|
|
|
}),
|
2023-02-16 03:06:44 +00:00
|
|
|
tsconfigPaths(),
|
2021-11-19 02:30:21 +00:00
|
|
|
viteCompression({
|
2023-02-16 03:06:44 +00:00
|
|
|
algorithm: "gzip",
|
|
|
|
deleteOriginFile: true,
|
2023-04-19 01:59:56 +00:00
|
|
|
threshold: 0,
|
2023-02-16 03:06:44 +00:00
|
|
|
filter: /\.(js|json|css|svg|md)$/i,
|
|
|
|
}),
|
2023-04-19 01:59:56 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
if (!nolegacy) {
|
|
|
|
plugins = [...plugins, legacy()];
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
base: "",
|
|
|
|
build: {
|
|
|
|
outDir: "build",
|
|
|
|
sourcemap: sourcemap,
|
|
|
|
reportCompressedSize: false,
|
|
|
|
},
|
|
|
|
optimizeDeps: {
|
|
|
|
entries: "src/index.tsx",
|
|
|
|
},
|
|
|
|
server: {
|
|
|
|
port: 3000,
|
|
|
|
cors: false,
|
|
|
|
},
|
|
|
|
publicDir: "public",
|
|
|
|
assetsInclude: ["**/*.md"],
|
|
|
|
plugins,
|
|
|
|
};
|
2023-02-16 03:06:44 +00:00
|
|
|
});
|