eo-services-client/vite.config.js

83 lines
2.3 KiB
JavaScript

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 href="/"/>',
},
},
}),
],
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 href="/eo-services/"/>',
},
},
}),
],
base: "/eo-services/",
resolve: {
alias: {
vue: "vue/dist/vue.esm-bundler",
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
},
};
}
});