第一、第二種方案
import path from "path";
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
import { viteSingleFile } from "vite-plugin-singlefile";
import legacy from "@vitejs/plugin-legacy";
// 基於不可控遠端的vite專案離線部署的多種方式
/* 把所有資源打包在一個index.html 體積較大 */
const SingleConfig = defineConfig({
resolve: {
alias: [
{
find: "@",
replacement: path.resolve(dirname, "./src")
}
]
},
plugins: [vue(), vueJsx(), vitesingleFile()]
})
// 使用webpack那種引入方式,不用type=module
const LegacyConfig = defineConfig({
base:"./",
resolve: {
alias: [
{
find: "@",
replacement: path.resolve(dirname, "./src")
}
]
},
plugins: [vue(), vueJsx(), legacy({targets:["defaults","not IE 11"]})]
})
第三種方案
pkg SEA Single Executable Applications