feat: 添加环境配置文件,更新.gitignore以排除dist-test目录,新增构建和预览测试脚本
This commit is contained in:
3
.env.test
Normal file
3
.env.test
Normal file
@@ -0,0 +1,3 @@
|
||||
VITE_API_URL=http://192.168.1.7:9527
|
||||
VITE_TRADINGVIEW_LIBRARY_URL=https://dev.riwsan1.com
|
||||
# VITE_TRADINGVIEW_DATA_API_URL=https://demo-feed-data.tradingview.com
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -26,6 +26,7 @@ npm-debug.log*
|
||||
!/.vscode/extensions.json
|
||||
/coverage
|
||||
/dist
|
||||
/dist-test
|
||||
/dev-dist
|
||||
/node_modules
|
||||
/platforms
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
"deploy:cloudflare": "wrangler pages deploy dist --project-name=riwa --branch=main",
|
||||
"test:e2e": "cypress run",
|
||||
"test:unit": "vitest",
|
||||
"test:build": "vite build -m test --outDir dist-test",
|
||||
"test:preview": "vite preview --port 6173 -m test --outDir dist-test",
|
||||
"lint": "eslint",
|
||||
"lint:fix": "eslint --fix"
|
||||
},
|
||||
|
||||
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