import { defineConfig } from "vite"; import { fileURLToPath, URL } from "node:url"; import vue from "@vitejs/plugin-vue"; import { createHtmlPlugin } from "vite-plugin-html"; // https://vitejs.dev/config/ export default defineConfig(({ command }) => { if (command === "serve") { return { // dev specific config plugins: [ vue(), createHtmlPlugin({ minify: true, /** * After writing entry here, you will not need to add script tags in `index.html`, the original tags need to be deleted * @default src/main.ts */ entry: "src/main.js", /** * If you want to store `index.html` in the specified folder, you can modify it, otherwise no configuration is required * @default index.html */ template: "index.html", /** * Data that needs to be injected into the index.html ejs template */ inject: { data: { baseHref: '', }, }, }), ], base: "/", resolve: { alias: { vue: "vue/dist/vue.esm-bundler", "@": fileURLToPath(new URL("./src", import.meta.url)), }, }, }; } else { // command === 'build' return { // build specific config plugins: [ vue(), createHtmlPlugin({ minify: true, /** * After writing entry here, you will not need to add script tags in `index.html`, the original tags need to be deleted * @default src/main.ts */ entry: "src/main.js", /** * If you want to store `index.html` in the specified folder, you can modify it, otherwise no configuration is required * @default index.html */ template: "index.html", /** * Data that needs to be injected into the index.html ejs template */ inject: { data: { baseHref: '', }, }, }), ], base: "/eo-services/", resolve: { alias: { vue: "vue/dist/vue.esm-bundler", "@": fileURLToPath(new URL("./src", import.meta.url)), }, }, }; } });