feat: 添加环境配置文件,更新.gitignore以排除dist-test目录,新增构建和预览测试脚本
This commit is contained in:
162
vite.config.ts
162
vite.config.ts
@@ -15,91 +15,93 @@ import { defineConfig } from "vite";
|
||||
import { VitePWA } from "vite-plugin-pwa";
|
||||
import { generateVersion } from "./scripts/build";
|
||||
|
||||
dotenv.config({ path: `.env.${process.env.NODE_ENV}` });
|
||||
|
||||
const packageJson = JSON.parse(fs.readFileSync("./package.json", "utf-8"));
|
||||
const appVersion = packageJson.version;
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
vue(),
|
||||
jsx(),
|
||||
legacy(),
|
||||
icons({
|
||||
autoInstall: true,
|
||||
}),
|
||||
tailwindcss(),
|
||||
autoImport({
|
||||
dirs: ["src/composables", "src/utils", "src/store"],
|
||||
imports: ["vue", "vue-router", "@vueuse/core", "vue-i18n", "pinia"],
|
||||
resolvers: [IonicResolver()],
|
||||
vueTemplate: true,
|
||||
}),
|
||||
components({
|
||||
directoryAsNamespace: true,
|
||||
resolvers: [IonicResolver(), iconsResolver({ prefix: "i" })],
|
||||
}),
|
||||
VitePWA({
|
||||
registerType: "autoUpdate",
|
||||
injectRegister: "auto",
|
||||
includeAssets: ["favicon.svg"],
|
||||
devOptions: {
|
||||
enabled: true,
|
||||
type: "module",
|
||||
},
|
||||
manifest: {
|
||||
name: "Riwsan 瑞讯",
|
||||
short_name: "Riwsan 瑞讯",
|
||||
description: "Riwsan - 下一代数字资产交易平台",
|
||||
theme_color: "#ffffff",
|
||||
background_color: "#ffffff",
|
||||
display: "standalone",
|
||||
orientation: "portrait",
|
||||
scope: "/",
|
||||
start_url: "/",
|
||||
id: "/",
|
||||
prefer_related_applications: false,
|
||||
icons: [
|
||||
{
|
||||
src: "/favicon.svg",
|
||||
sizes: "any",
|
||||
type: "image/svg+xml",
|
||||
purpose: "any maskable",
|
||||
},
|
||||
],
|
||||
},
|
||||
workbox: {
|
||||
globPatterns: ["**/*.{js,css,html,ico,png,svg,woff2}"],
|
||||
navigateFallback: "/index.html",
|
||||
navigateFallbackDenylist: [/^\/api/],
|
||||
cleanupOutdatedCaches: true,
|
||||
clientsClaim: true,
|
||||
skipWaiting: true,
|
||||
maximumFileSizeToCacheInBytes: 100 * 1024 * 1024, // 100 MB
|
||||
},
|
||||
}),
|
||||
// basicSsl(),
|
||||
generateVersion({
|
||||
version: appVersion,
|
||||
}),
|
||||
],
|
||||
define: {
|
||||
__APP_VERSION__: JSON.stringify(appVersion),
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": path.resolve(__dirname, "./src"),
|
||||
export default defineConfig(({ mode }) => {
|
||||
dotenv.config({ path: `.env.${mode}` });
|
||||
|
||||
return {
|
||||
plugins: [
|
||||
vue(),
|
||||
jsx(),
|
||||
legacy(),
|
||||
icons({
|
||||
autoInstall: true,
|
||||
}),
|
||||
tailwindcss(),
|
||||
autoImport({
|
||||
dirs: ["src/composables", "src/utils", "src/store"],
|
||||
imports: ["vue", "vue-router", "@vueuse/core", "vue-i18n", "pinia"],
|
||||
resolvers: [IonicResolver()],
|
||||
vueTemplate: true,
|
||||
}),
|
||||
components({
|
||||
directoryAsNamespace: true,
|
||||
resolvers: [IonicResolver(), iconsResolver({ prefix: "i" })],
|
||||
}),
|
||||
VitePWA({
|
||||
registerType: "autoUpdate",
|
||||
injectRegister: "auto",
|
||||
includeAssets: ["favicon.svg"],
|
||||
devOptions: {
|
||||
enabled: true,
|
||||
type: "module",
|
||||
},
|
||||
manifest: {
|
||||
name: "Riwsan 瑞讯",
|
||||
short_name: "Riwsan 瑞讯",
|
||||
description: "Riwsan - 下一代数字资产交易平台",
|
||||
theme_color: "#ffffff",
|
||||
background_color: "#ffffff",
|
||||
display: "standalone",
|
||||
orientation: "portrait",
|
||||
scope: "/",
|
||||
start_url: "/",
|
||||
id: "/",
|
||||
prefer_related_applications: false,
|
||||
icons: [
|
||||
{
|
||||
src: "/favicon.svg",
|
||||
sizes: "any",
|
||||
type: "image/svg+xml",
|
||||
purpose: "any maskable",
|
||||
},
|
||||
],
|
||||
},
|
||||
workbox: {
|
||||
globPatterns: ["**/*.{js,css,html,ico,png,svg,woff2}"],
|
||||
navigateFallback: "/index.html",
|
||||
navigateFallbackDenylist: [/^\/api/],
|
||||
cleanupOutdatedCaches: true,
|
||||
clientsClaim: true,
|
||||
skipWaiting: true,
|
||||
maximumFileSizeToCacheInBytes: 100 * 1024 * 1024, // 100 MB
|
||||
},
|
||||
}),
|
||||
// basicSsl(),
|
||||
generateVersion({
|
||||
version: appVersion,
|
||||
}),
|
||||
],
|
||||
define: {
|
||||
__APP_VERSION__: JSON.stringify(appVersion),
|
||||
},
|
||||
},
|
||||
server: {
|
||||
host: true,
|
||||
proxy: {
|
||||
"/api": {
|
||||
target: process.env.VITE_API_URL,
|
||||
changeOrigin: true,
|
||||
ws: true,
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": path.resolve(__dirname, "./src"),
|
||||
},
|
||||
},
|
||||
},
|
||||
server: {
|
||||
host: true,
|
||||
proxy: {
|
||||
"/api": {
|
||||
target: process.env.VITE_API_URL,
|
||||
changeOrigin: true,
|
||||
ws: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user