dev #3
18
.env
18
.env
|
@ -1,5 +1,17 @@
|
||||||
# 平台本地运行端口号
|
# 平台本地运行端口号
|
||||||
VITE_PORT = 8848
|
VITE_PORT=8202
|
||||||
|
|
||||||
|
# 预发布环境路由历史模式(Hash模式传"hash"、HTML5模式传"h5"、Hash模式带base参数传"hash,base参数"、HTML5模式带base参数传"h5,base参数")
|
||||||
|
VITE_ROUTER_HISTORY="hash"
|
||||||
|
|
||||||
|
# 跨域代理地址
|
||||||
|
VITE_APP_URL="http://localhost:8801"
|
||||||
|
|
||||||
|
# 是否在打包时使用cdn替换本地库 替换 true 不替换 false
|
||||||
|
VITE_CDN=true
|
||||||
|
|
||||||
|
# 是否启用gzip压缩或brotli压缩(分两种情况,删除原始文件和不删除原始文件)
|
||||||
|
# 压缩时不删除原始文件的配置:gzip、brotli、both(同时开启 gzip 与 brotli 压缩)、none(不开启压缩,默认)
|
||||||
|
# 压缩时删除原始文件的配置:gzip-clear、brotli-clear、both-clear(同时开启 gzip 与 brotli 压缩)、none(不开启压缩,默认)
|
||||||
|
VITE_COMPRESSION="none"
|
||||||
|
|
||||||
# 是否隐藏首页 隐藏 true 不隐藏 false (勿删除,VITE_HIDE_HOME只需在.env文件配置)
|
|
||||||
VITE_HIDE_HOME = false
|
|
||||||
|
|
|
@ -1,8 +1,17 @@
|
||||||
# 平台本地运行端口号
|
# 平台本地运行端口号
|
||||||
VITE_PORT = 8848
|
VITE_PORT=8202
|
||||||
|
|
||||||
# 开发环境读取配置文件路径
|
# 预发布环境路由历史模式(Hash模式传"hash"、HTML5模式传"h5"、Hash模式带base参数传"hash,base参数"、HTML5模式带base参数传"h5,base参数")
|
||||||
VITE_PUBLIC_PATH = /
|
|
||||||
|
|
||||||
# 开发环境路由历史模式(Hash模式传"hash"、HTML5模式传"h5"、Hash模式带base参数传"hash,base参数"、HTML5模式带base参数传"h5,base参数")
|
|
||||||
VITE_ROUTER_HISTORY="hash"
|
VITE_ROUTER_HISTORY="hash"
|
||||||
|
|
||||||
|
# 跨域代理地址
|
||||||
|
VITE_APP_URL="http://localhost:8801"
|
||||||
|
|
||||||
|
# 是否在打包时使用cdn替换本地库 替换 true 不替换 false
|
||||||
|
VITE_CDN=true
|
||||||
|
|
||||||
|
# 是否启用gzip压缩或brotli压缩(分两种情况,删除原始文件和不删除原始文件)
|
||||||
|
# 压缩时不删除原始文件的配置:gzip、brotli、both(同时开启 gzip 与 brotli 压缩)、none(不开启压缩,默认)
|
||||||
|
# 压缩时删除原始文件的配置:gzip-clear、brotli-clear、both-clear(同时开启 gzip 与 brotli 压缩)、none(不开启压缩,默认)
|
||||||
|
VITE_COMPRESSION="none"
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
# 线上环境平台打包路径
|
# 平台本地运行端口号
|
||||||
VITE_PUBLIC_PATH = /
|
VITE_PORT=8202
|
||||||
|
|
||||||
# 线上环境路由历史模式(Hash模式传"hash"、HTML5模式传"h5"、Hash模式带base参数传"hash,base参数"、HTML5模式带base参数传"h5,base参数")
|
# 预发布环境路由历史模式(Hash模式传"hash"、HTML5模式传"h5"、Hash模式带base参数传"hash,base参数"、HTML5模式带base参数传"h5,base参数")
|
||||||
VITE_ROUTER_HISTORY="hash"
|
VITE_ROUTER_HISTORY="hash"
|
||||||
|
|
||||||
|
# 跨域代理地址
|
||||||
|
VITE_APP_URL="http://localhost:8801"
|
||||||
|
|
||||||
# 是否在打包时使用cdn替换本地库 替换 true 不替换 false
|
# 是否在打包时使用cdn替换本地库 替换 true 不替换 false
|
||||||
VITE_CDN = false
|
VITE_CDN=true
|
||||||
|
|
||||||
# 是否启用gzip压缩或brotli压缩(分两种情况,删除原始文件和不删除原始文件)
|
# 是否启用gzip压缩或brotli压缩(分两种情况,删除原始文件和不删除原始文件)
|
||||||
# 压缩时不删除原始文件的配置:gzip、brotli、both(同时开启 gzip 与 brotli 压缩)、none(不开启压缩,默认)
|
# 压缩时不删除原始文件的配置:gzip、brotli、both(同时开启 gzip 与 brotli 压缩)、none(不开启压缩,默认)
|
||||||
# 压缩时删除原始文件的配置:gzip-clear、brotli-clear、both-clear(同时开启 gzip 与 brotli 压缩)、none(不开启压缩,默认)
|
# 压缩时删除原始文件的配置:gzip-clear、brotli-clear、both-clear(同时开启 gzip 与 brotli 压缩)、none(不开启压缩,默认)
|
||||||
VITE_COMPRESSION="none"
|
VITE_COMPRESSION="none"
|
||||||
|
|
||||||
|
|
11
.env.staging
11
.env.staging
|
@ -1,12 +1,12 @@
|
||||||
# 预发布也需要生产环境的行为
|
# 平台本地运行端口号
|
||||||
# https://cn.vitejs.dev/guide/env-and-mode.html#modes
|
VITE_PORT=8202
|
||||||
# NODE_ENV = development
|
|
||||||
|
|
||||||
VITE_PUBLIC_PATH = /
|
|
||||||
|
|
||||||
# 预发布环境路由历史模式(Hash模式传"hash"、HTML5模式传"h5"、Hash模式带base参数传"hash,base参数"、HTML5模式带base参数传"h5,base参数")
|
# 预发布环境路由历史模式(Hash模式传"hash"、HTML5模式传"h5"、Hash模式带base参数传"hash,base参数"、HTML5模式带base参数传"h5,base参数")
|
||||||
VITE_ROUTER_HISTORY="hash"
|
VITE_ROUTER_HISTORY="hash"
|
||||||
|
|
||||||
|
# 跨域代理地址
|
||||||
|
VITE_APP_URL="http://localhost:8801"
|
||||||
|
|
||||||
# 是否在打包时使用cdn替换本地库 替换 true 不替换 false
|
# 是否在打包时使用cdn替换本地库 替换 true 不替换 false
|
||||||
VITE_CDN=true
|
VITE_CDN=true
|
||||||
|
|
||||||
|
@ -14,3 +14,4 @@ VITE_CDN = true
|
||||||
# 压缩时不删除原始文件的配置:gzip、brotli、both(同时开启 gzip 与 brotli 压缩)、none(不开启压缩,默认)
|
# 压缩时不删除原始文件的配置:gzip、brotli、both(同时开启 gzip 与 brotli 压缩)、none(不开启压缩,默认)
|
||||||
# 压缩时删除原始文件的配置:gzip-clear、brotli-clear、both-clear(同时开启 gzip 与 brotli 压缩)、none(不开启压缩,默认)
|
# 压缩时删除原始文件的配置:gzip-clear、brotli-clear、both-clear(同时开启 gzip 与 brotli 压缩)、none(不开启压缩,默认)
|
||||||
VITE_COMPRESSION="none"
|
VITE_COMPRESSION="none"
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
import { pathResolve } from './utils';
|
||||||
|
import type { BuildOptions } from 'vite';
|
||||||
|
|
||||||
|
export const buildEnvironment = () => {
|
||||||
|
const environment: BuildOptions = {
|
||||||
|
target: 'es2015',
|
||||||
|
assetsInlineLimit: 20000,
|
||||||
|
// 构建输出的目录,默认值为"dist"
|
||||||
|
outDir: 'dist',
|
||||||
|
// 用于指定使用的代码压缩工具。在这里,minify 被设置为 'terser',表示使用 Terser 进行代码压缩。默认值terser
|
||||||
|
// esbuild 打包更快,但是不能去除 console.log,terser打包慢,但能去除 console.log
|
||||||
|
minify: 'terser',
|
||||||
|
// 用于配置 Terser 的选项
|
||||||
|
terserOptions: {
|
||||||
|
// 用于配置压缩选项
|
||||||
|
compress: {
|
||||||
|
drop_console: true, // 是否删除代码中的 console 语句, 默认值false
|
||||||
|
drop_debugger: true, // 是否删除代码中的 debugger 语句, 默认值false
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// 禁用 gzip 压缩大小报告,可略微减少打包时间
|
||||||
|
reportCompressedSize: false,
|
||||||
|
// 用于指定是否生成源映射文件。源映射文件可以帮助调试和定位源代码中的错误。当设置为false时,构建过程不会生成源映射文件
|
||||||
|
sourcemap: false,
|
||||||
|
// 用于配置 CommonJS 模块的选项
|
||||||
|
commonjsOptions: {
|
||||||
|
// 用于指定是否忽略 CommonJS 模块中的 try-catch 语句。当设置为false时,构建过程会保留 CommonJS 模块中的 try-catch 语句
|
||||||
|
ignoreTryCatch: false,
|
||||||
|
},
|
||||||
|
// 规定触发警告的 chunk 大小, 当某个代码分块的大小超过该限制时,Vite 会发出警告
|
||||||
|
chunkSizeWarningLimit: 2000,
|
||||||
|
rollupOptions: {
|
||||||
|
input: {
|
||||||
|
index: pathResolve('../index.html', import.meta.url),
|
||||||
|
},
|
||||||
|
// 静态资源分类打包
|
||||||
|
output: {
|
||||||
|
chunkFileNames: 'static/js/[name]-[hash].js',
|
||||||
|
entryFileNames: 'static/js/[name]-[hash].js',
|
||||||
|
assetFileNames: 'static/[ext]/[name]-[hash].[ext]',
|
||||||
|
manualChunks: id => {
|
||||||
|
// 如果是包含在包中则打包成 vendor
|
||||||
|
if (id.includes('node_modules')) {
|
||||||
|
return 'vendor';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return environment;
|
||||||
|
};
|
65
build/cdn.ts
65
build/cdn.ts
|
@ -1,4 +1,4 @@
|
||||||
import { Plugin as importToCDN } from "vite-plugin-cdn-import";
|
import { Plugin as importToCDN } from 'vite-plugin-cdn-import';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 打包时采用`cdn`模式,仅限外网使用(默认不采用,如果需要采用cdn模式,请在 .env.production 文件,将 VITE_CDN 设置成true)
|
* @description 打包时采用`cdn`模式,仅限外网使用(默认不采用,如果需要采用cdn模式,请在 .env.production 文件,将 VITE_CDN 设置成true)
|
||||||
|
@ -7,54 +7,55 @@ import { Plugin as importToCDN } from "vite-plugin-cdn-import";
|
||||||
*/
|
*/
|
||||||
export const cdn = importToCDN({
|
export const cdn = importToCDN({
|
||||||
//(prodUrl解释: name: 对应下面modules的name,version: 自动读取本地package.json中dependencies依赖中对应包的版本号,path: 对应下面modules的path,当然也可写完整路径,会替换prodUrl)
|
//(prodUrl解释: name: 对应下面modules的name,version: 自动读取本地package.json中dependencies依赖中对应包的版本号,path: 对应下面modules的path,当然也可写完整路径,会替换prodUrl)
|
||||||
prodUrl: "https://cdn.bootcdn.net/ajax/libs/{name}/{version}/{path}",
|
// prodUrl: 'https://cdn.bootcdn.net/ajax/libs/{name}/{version}/{path}',
|
||||||
|
prodUrl: 'https://unpkg.com/{name}@{version}/{path}',
|
||||||
modules: [
|
modules: [
|
||||||
{
|
{
|
||||||
name: "vue",
|
name: 'vue',
|
||||||
var: "Vue",
|
var: 'Vue',
|
||||||
path: "vue.global.prod.min.js"
|
path: 'dist/vue.global.js',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "vue-router",
|
name: 'vue-router',
|
||||||
var: "VueRouter",
|
var: 'VueRouter',
|
||||||
path: "vue-router.global.min.js"
|
path: 'dist/vue-router.global.js',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "vue-i18n",
|
name: 'vue-i18n',
|
||||||
var: "VueI18n",
|
var: 'VueI18n',
|
||||||
path: "vue-i18n.runtime.global.prod.min.js"
|
path: 'dist/vue-i18n.global.js',
|
||||||
},
|
},
|
||||||
// 项目中没有直接安装vue-demi,但是pinia用到了,所以需要在引入pinia前引入vue-demi(https://github.com/vuejs/pinia/blob/v2/packages/pinia/package.json#L77)
|
// 项目中没有直接安装vue-demi,但是pinia用到了,所以需要在引入pinia前引入vue-demi(https://github.com/vuejs/pinia/blob/v2/packages/pinia/package.json#L77)
|
||||||
{
|
{
|
||||||
name: "vue-demi",
|
name: 'vue-demi',
|
||||||
var: "VueDemi",
|
var: 'VueDemi',
|
||||||
path: "index.iife.min.js"
|
path: 'lib/index.iife.js',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "pinia",
|
name: 'pinia',
|
||||||
var: "Pinia",
|
var: 'Pinia',
|
||||||
path: "pinia.iife.min.js"
|
path: 'dist/pinia.iife.js',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "element-plus",
|
name: 'element-plus',
|
||||||
var: "ElementPlus",
|
var: 'ElementPlus',
|
||||||
path: "index.full.min.js",
|
path: 'dist/index.full.js',
|
||||||
css: "index.min.css"
|
css: 'dist/index.css',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "axios",
|
name: 'axios',
|
||||||
var: "axios",
|
var: 'axios',
|
||||||
path: "axios.min.js"
|
path: 'dist/axios.min.js',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "dayjs",
|
name: 'dayjs',
|
||||||
var: "dayjs",
|
var: 'dayjs',
|
||||||
path: "dayjs.min.js"
|
path: 'dayjs.min.js',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "echarts",
|
name: 'echarts',
|
||||||
var: "echarts",
|
var: 'echarts',
|
||||||
path: "echarts.min.js"
|
path: 'dist/echarts.js',
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,51 +1,45 @@
|
||||||
import type { Plugin } from "vite";
|
import type { Plugin } from 'vite';
|
||||||
import { isArray } from "@pureadmin/utils";
|
import { isArray } from '@pureadmin/utils';
|
||||||
import compressPlugin from "vite-plugin-compression";
|
import compressPlugin from 'vite-plugin-compression';
|
||||||
|
|
||||||
export const configCompressPlugin = (
|
export const configCompressPlugin = (compress: ViteCompression): Plugin | Plugin[] => {
|
||||||
compress: ViteCompression
|
if (compress === 'none') return null;
|
||||||
): Plugin | Plugin[] => {
|
|
||||||
if (compress === "none") return null;
|
|
||||||
|
|
||||||
const gz = {
|
const gz = {
|
||||||
// 生成的压缩包后缀
|
// 生成的压缩包后缀
|
||||||
ext: ".gz",
|
ext: '.gz',
|
||||||
// 体积大于threshold才会被压缩
|
// 体积大于threshold才会被压缩
|
||||||
threshold: 0,
|
threshold: 0,
|
||||||
// 默认压缩.js|mjs|json|css|html后缀文件,设置成true,压缩全部文件
|
// 默认压缩.js|mjs|json|css|html后缀文件,设置成true,压缩全部文件
|
||||||
filter: () => true,
|
filter: () => true,
|
||||||
// 压缩后是否删除原始文件
|
// 压缩后是否删除原始文件
|
||||||
deleteOriginFile: false
|
deleteOriginFile: false,
|
||||||
};
|
};
|
||||||
const br = {
|
const br = {
|
||||||
ext: ".br",
|
ext: '.br',
|
||||||
algorithm: "brotliCompress",
|
algorithm: 'brotliCompress',
|
||||||
threshold: 0,
|
threshold: 0,
|
||||||
filter: () => true,
|
filter: () => true,
|
||||||
deleteOriginFile: false
|
deleteOriginFile: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const codeList = [
|
const codeList = [
|
||||||
{ k: "gzip", v: gz },
|
{ k: 'gzip', v: gz },
|
||||||
{ k: "brotli", v: br },
|
{ k: 'brotli', v: br },
|
||||||
{ k: "both", v: [gz, br] }
|
{ k: 'both', v: [gz, br] },
|
||||||
];
|
];
|
||||||
|
|
||||||
const plugins: Plugin[] = [];
|
const plugins: Plugin[] = [];
|
||||||
|
|
||||||
codeList.forEach(item => {
|
codeList.forEach(item => {
|
||||||
if (compress.includes(item.k)) {
|
if (compress.includes(item.k)) {
|
||||||
if (compress.includes("clear")) {
|
if (compress.includes('clear')) {
|
||||||
if (isArray(item.v)) {
|
if (isArray(item.v)) {
|
||||||
item.v.forEach(vItem => {
|
item.v.forEach(vItem => {
|
||||||
plugins.push(
|
plugins.push(compressPlugin(Object.assign(vItem, { deleteOriginFile: true })));
|
||||||
compressPlugin(Object.assign(vItem, { deleteOriginFile: true }))
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
plugins.push(
|
plugins.push(compressPlugin(Object.assign(item.v, { deleteOriginFile: true })));
|
||||||
compressPlugin(Object.assign(item.v, { deleteOriginFile: true }))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (isArray(item.v)) {
|
if (isArray(item.v)) {
|
||||||
|
|
|
@ -1,22 +1,25 @@
|
||||||
import type { Plugin } from "vite";
|
import type { Plugin } from 'vite';
|
||||||
import { getPackageSize } from "./utils";
|
import { getPackageSize } from './utils';
|
||||||
import dayjs, { type Dayjs } from "dayjs";
|
import dayjs, { type Dayjs } from 'dayjs';
|
||||||
import duration from "dayjs/plugin/duration";
|
import duration from 'dayjs/plugin/duration';
|
||||||
import gradientString from "gradient-string";
|
import gradientString from 'gradient-string';
|
||||||
import boxen, { type Options as BoxenOptions } from "boxen";
|
import boxen, { type Options as BoxenOptions } from 'boxen';
|
||||||
|
|
||||||
dayjs.extend(duration);
|
dayjs.extend(duration);
|
||||||
|
|
||||||
const welcomeMessage = gradientString("cyan", "magenta").multiline(
|
const welcomeMessage = gradientString('cyan', 'magenta').multiline(
|
||||||
`您好! 欢迎使用 bunny-admin 后台管理
|
`您好! 欢迎使用 bunny-admin 后台管理
|
||||||
项目访问地址如下:
|
项目开发访问地址如下:
|
||||||
http://localhost:8848/`
|
http://localhost:8202/
|
||||||
|
项目生产访问地址如下:
|
||||||
|
http://localhost:8202/
|
||||||
|
`,
|
||||||
);
|
);
|
||||||
|
|
||||||
const boxenOptions: BoxenOptions = {
|
const boxenOptions: BoxenOptions = {
|
||||||
padding: 0.5,
|
padding: 0.5,
|
||||||
borderColor: "cyan",
|
borderColor: 'cyan',
|
||||||
borderStyle: "round"
|
borderStyle: 'round',
|
||||||
};
|
};
|
||||||
|
|
||||||
export function viteBuildInfo(): Plugin {
|
export function viteBuildInfo(): Plugin {
|
||||||
|
@ -25,27 +28,27 @@ export function viteBuildInfo(): Plugin {
|
||||||
let endTime: Dayjs;
|
let endTime: Dayjs;
|
||||||
let outDir: string;
|
let outDir: string;
|
||||||
return {
|
return {
|
||||||
name: "vite:buildInfo",
|
name: 'vite:buildInfo',
|
||||||
configResolved(resolvedConfig) {
|
configResolved(resolvedConfig) {
|
||||||
config = resolvedConfig;
|
config = resolvedConfig;
|
||||||
outDir = resolvedConfig.build?.outDir ?? "dist";
|
outDir = resolvedConfig.build?.outDir ?? 'dist';
|
||||||
},
|
},
|
||||||
buildStart() {
|
buildStart() {
|
||||||
console.log(boxen(welcomeMessage, boxenOptions));
|
console.log(boxen(welcomeMessage, boxenOptions));
|
||||||
if (config.command === "build") {
|
if (config.command === 'build') {
|
||||||
startTime = dayjs(new Date());
|
startTime = dayjs(new Date());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
closeBundle() {
|
closeBundle() {
|
||||||
if (config.command === "build") {
|
if (config.command === 'build') {
|
||||||
endTime = dayjs(new Date());
|
endTime = dayjs(new Date());
|
||||||
getPackageSize({
|
getPackageSize({
|
||||||
folder: outDir,
|
folder: outDir,
|
||||||
callback: (size: string) => {
|
callback: (size: string) => {
|
||||||
console.log(boxen(gradientString("cyan", "magenta").multiline(`🎉 恭喜打包完成(总用时${dayjs.duration(endTime.diff(startTime)).format("mm分ss秒")},打包后的大小为${size})`), boxenOptions));
|
console.log(boxen(gradientString('cyan', 'magenta').multiline(`🎉 恭喜打包完成(总用时${dayjs.duration(endTime.diff(startTime)).format('mm分ss秒')},打包后的大小为${size})`), boxenOptions));
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
import { loadEnv, type ServerOptions } from 'vite';
|
||||||
|
import { root, wrapperEnv } from './utils';
|
||||||
|
|
||||||
|
export const serverOptions = (mode: string) => {
|
||||||
|
const { VITE_PORT, VITE_APP_URL } = wrapperEnv(loadEnv(mode, root));
|
||||||
|
|
||||||
|
const options: ServerOptions = {
|
||||||
|
port: VITE_PORT, // ? 端口号
|
||||||
|
host: '0.0.0.0',
|
||||||
|
proxy: {
|
||||||
|
'/api': {
|
||||||
|
target: VITE_APP_URL,
|
||||||
|
changeOrigin: true,
|
||||||
|
rewrite: (path: string) => path.replace(/^\/api/, '/api'),
|
||||||
|
},
|
||||||
|
'/mock': {
|
||||||
|
target: VITE_APP_URL,
|
||||||
|
changeOrigin: true,
|
||||||
|
rewrite: (path: string) => path.replace(/^\/mock/, '/mock'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// 预热文件以提前转换和缓存结果,降低启动期间的初始页面加载时长并防止转换瀑布
|
||||||
|
warmup: {
|
||||||
|
clientFiles: ['./index.html', './src/{views,components}/*'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return options;
|
||||||
|
};
|
|
@ -34,7 +34,6 @@ const alias: Record<string, string> = {
|
||||||
'@': pathResolve('../src'),
|
'@': pathResolve('../src'),
|
||||||
'@build': pathResolve(),
|
'@build': pathResolve(),
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 平台的名称、版本、运行所需的`node`和`pnpm`版本、依赖、最后构建时间的类型提示 */
|
/** 平台的名称、版本、运行所需的`node`和`pnpm`版本、依赖、最后构建时间的类型提示 */
|
||||||
const __APP_INFO__ = {
|
const __APP_INFO__ = {
|
||||||
pkg: { name, version, engines, dependencies, devDependencies },
|
pkg: { name, version, engines, dependencies, devDependencies },
|
||||||
|
@ -43,14 +42,12 @@ const __APP_INFO__ = {
|
||||||
|
|
||||||
/** 处理环境变量 */
|
/** 处理环境变量 */
|
||||||
const wrapperEnv = (envConf: Recordable): ViteEnv => {
|
const wrapperEnv = (envConf: Recordable): ViteEnv => {
|
||||||
// 默认值
|
// TODO 默认值
|
||||||
const ret: ViteEnv = {
|
const ret: ViteEnv = {
|
||||||
VITE_PORT: 8848,
|
VITE_PORT: 8848,
|
||||||
VITE_PUBLIC_PATH: '',
|
VITE_APP_URL: '',
|
||||||
VITE_ROUTER_HISTORY: '',
|
VITE_COMPRESSION: 'gzip',
|
||||||
VITE_CDN: false,
|
VITE_CDN: true,
|
||||||
VITE_HIDE_HOME: 'false',
|
|
||||||
VITE_COMPRESSION: 'none',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const envName of Object.keys(envConf)) {
|
for (const envName of Object.keys(envConf)) {
|
||||||
|
@ -67,6 +64,7 @@ const wrapperEnv = (envConf: Recordable): ViteEnv => {
|
||||||
process.env[envName] = JSON.stringify(realName);
|
process.env[envName] = JSON.stringify(realName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,7 @@
|
||||||
"responsive-storage": "^2.2.0",
|
"responsive-storage": "^2.2.0",
|
||||||
"sortablejs": "^1.15.2",
|
"sortablejs": "^1.15.2",
|
||||||
"swiper": "^11.1.1",
|
"swiper": "^11.1.1",
|
||||||
|
"terser": "^5.31.0",
|
||||||
"typeit": "^8.8.3",
|
"typeit": "^8.8.3",
|
||||||
"v-contextmenu": "^3.2.0",
|
"v-contextmenu": "^3.2.0",
|
||||||
"v3-infinite-loading": "^1.3.1",
|
"v3-infinite-loading": "^1.3.1",
|
||||||
|
|
|
@ -131,6 +131,9 @@ importers:
|
||||||
swiper:
|
swiper:
|
||||||
specifier: ^11.1.1
|
specifier: ^11.1.1
|
||||||
version: 11.1.3
|
version: 11.1.3
|
||||||
|
terser:
|
||||||
|
specifier: ^5.31.0
|
||||||
|
version: 5.31.0
|
||||||
typeit:
|
typeit:
|
||||||
specifier: ^8.8.3
|
specifier: ^8.8.3
|
||||||
version: 8.8.3
|
version: 8.8.3
|
||||||
|
@ -257,10 +260,10 @@ importers:
|
||||||
version: 7.10.0(eslint@9.3.0)(typescript@5.4.5)
|
version: 7.10.0(eslint@9.3.0)(typescript@5.4.5)
|
||||||
'@vitejs/plugin-vue':
|
'@vitejs/plugin-vue':
|
||||||
specifier: ^5.0.4
|
specifier: ^5.0.4
|
||||||
version: 5.0.4(vite@5.2.11(@types/node@20.12.12)(sass@1.77.2))(vue@3.4.27(typescript@5.4.5))
|
version: 5.0.4(vite@5.2.11(@types/node@20.12.12)(sass@1.77.2)(terser@5.31.0))(vue@3.4.27(typescript@5.4.5))
|
||||||
'@vitejs/plugin-vue-jsx':
|
'@vitejs/plugin-vue-jsx':
|
||||||
specifier: ^3.1.0
|
specifier: ^3.1.0
|
||||||
version: 3.1.0(vite@5.2.11(@types/node@20.12.12)(sass@1.77.2))(vue@3.4.27(typescript@5.4.5))
|
version: 3.1.0(vite@5.2.11(@types/node@20.12.12)(sass@1.77.2)(terser@5.31.0))(vue@3.4.27(typescript@5.4.5))
|
||||||
autoprefixer:
|
autoprefixer:
|
||||||
specifier: ^10.4.19
|
specifier: ^10.4.19
|
||||||
version: 10.4.19(postcss@8.4.38)
|
version: 10.4.19(postcss@8.4.38)
|
||||||
|
@ -356,13 +359,13 @@ importers:
|
||||||
version: 5.4.5
|
version: 5.4.5
|
||||||
vite:
|
vite:
|
||||||
specifier: ^5.2.11
|
specifier: ^5.2.11
|
||||||
version: 5.2.11(@types/node@20.12.12)(sass@1.77.2)
|
version: 5.2.11(@types/node@20.12.12)(sass@1.77.2)(terser@5.31.0)
|
||||||
vite-plugin-cdn-import:
|
vite-plugin-cdn-import:
|
||||||
specifier: ^0.3.5
|
specifier: ^0.3.5
|
||||||
version: 0.3.5(rollup@4.18.0)
|
version: 0.3.5(rollup@4.18.0)
|
||||||
vite-plugin-compression:
|
vite-plugin-compression:
|
||||||
specifier: ^0.5.1
|
specifier: ^0.5.1
|
||||||
version: 0.5.1(vite@5.2.11(@types/node@20.12.12)(sass@1.77.2))
|
version: 0.5.1(vite@5.2.11(@types/node@20.12.12)(sass@1.77.2)(terser@5.31.0))
|
||||||
vite-plugin-fake-server:
|
vite-plugin-fake-server:
|
||||||
specifier: ^2.1.1
|
specifier: ^2.1.1
|
||||||
version: 2.1.1
|
version: 2.1.1
|
||||||
|
@ -1250,6 +1253,9 @@ packages:
|
||||||
resolution: {integrity: sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==}
|
resolution: {integrity: sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==}
|
||||||
engines: {node: '>=6.0.0'}
|
engines: {node: '>=6.0.0'}
|
||||||
|
|
||||||
|
'@jridgewell/source-map@0.3.6':
|
||||||
|
resolution: {integrity: sha512-1ZJTZebgqllO79ue2bm3rIGud/bOe0pP5BjSRCRxxYkEZS8STV7zN84UBbiYu7jy+eCKSnVIUgoWWE/tt+shMQ==}
|
||||||
|
|
||||||
'@jridgewell/sourcemap-codec@1.4.15':
|
'@jridgewell/sourcemap-codec@1.4.15':
|
||||||
resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==}
|
resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==}
|
||||||
|
|
||||||
|
@ -2289,6 +2295,9 @@ packages:
|
||||||
resolution: {integrity: sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==}
|
resolution: {integrity: sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
|
|
||||||
|
commander@2.20.3:
|
||||||
|
resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==}
|
||||||
|
|
||||||
commander@4.1.1:
|
commander@4.1.1:
|
||||||
resolution: {integrity: sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==}
|
resolution: {integrity: sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==}
|
||||||
engines: {node: '>= 6'}
|
engines: {node: '>= 6'}
|
||||||
|
@ -5395,6 +5404,11 @@ packages:
|
||||||
resolution: {integrity: sha512-un0FmiRUQNr5PJqy9kP7c40F5BOfpGlYTrxonDChEZB7pzZxRNp/bt+ymiy9/npwXya9KH99nJ/GXFIiUkYGFQ==}
|
resolution: {integrity: sha512-un0FmiRUQNr5PJqy9kP7c40F5BOfpGlYTrxonDChEZB7pzZxRNp/bt+ymiy9/npwXya9KH99nJ/GXFIiUkYGFQ==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
|
|
||||||
|
terser@5.31.0:
|
||||||
|
resolution: {integrity: sha512-Q1JFAoUKE5IMfI4Z/lkE/E6+SwgzO+x4tq4v1AyBLRj8VSYvRO6A/rQrPg1yud4g0En9EKI1TvFRF2tQFcoUkg==}
|
||||||
|
engines: {node: '>=10'}
|
||||||
|
hasBin: true
|
||||||
|
|
||||||
test-exclude@6.0.0:
|
test-exclude@6.0.0:
|
||||||
resolution: {integrity: sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==}
|
resolution: {integrity: sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
|
@ -6376,7 +6390,7 @@ snapshots:
|
||||||
lodash.merge: 4.6.2
|
lodash.merge: 4.6.2
|
||||||
lodash.uniq: 4.5.0
|
lodash.uniq: 4.5.0
|
||||||
resolve-from: 5.0.0
|
resolve-from: 5.0.0
|
||||||
ts-node: 10.9.2(@types/node@20.5.1)(typescript@5.4.5)
|
ts-node: 10.9.2(@types/node@20.12.12)(typescript@5.4.5)
|
||||||
typescript: 5.4.5
|
typescript: 5.4.5
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- '@swc/core'
|
- '@swc/core'
|
||||||
|
@ -6954,6 +6968,11 @@ snapshots:
|
||||||
|
|
||||||
'@jridgewell/set-array@1.2.1': {}
|
'@jridgewell/set-array@1.2.1': {}
|
||||||
|
|
||||||
|
'@jridgewell/source-map@0.3.6':
|
||||||
|
dependencies:
|
||||||
|
'@jridgewell/gen-mapping': 0.3.5
|
||||||
|
'@jridgewell/trace-mapping': 0.3.25
|
||||||
|
|
||||||
'@jridgewell/sourcemap-codec@1.4.15': {}
|
'@jridgewell/sourcemap-codec@1.4.15': {}
|
||||||
|
|
||||||
'@jridgewell/trace-mapping@0.3.25':
|
'@jridgewell/trace-mapping@0.3.25':
|
||||||
|
@ -7394,19 +7413,19 @@ snapshots:
|
||||||
'@uppy/utils': 4.1.3
|
'@uppy/utils': 4.1.3
|
||||||
nanoid: 3.3.7
|
nanoid: 3.3.7
|
||||||
|
|
||||||
'@vitejs/plugin-vue-jsx@3.1.0(vite@5.2.11(@types/node@20.12.12)(sass@1.77.2))(vue@3.4.27(typescript@5.4.5))':
|
'@vitejs/plugin-vue-jsx@3.1.0(vite@5.2.11(@types/node@20.12.12)(sass@1.77.2)(terser@5.31.0))(vue@3.4.27(typescript@5.4.5))':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/core': 7.24.6
|
'@babel/core': 7.24.6
|
||||||
'@babel/plugin-transform-typescript': 7.24.6(@babel/core@7.24.6)
|
'@babel/plugin-transform-typescript': 7.24.6(@babel/core@7.24.6)
|
||||||
'@vue/babel-plugin-jsx': 1.2.2(@babel/core@7.24.6)
|
'@vue/babel-plugin-jsx': 1.2.2(@babel/core@7.24.6)
|
||||||
vite: 5.2.11(@types/node@20.12.12)(sass@1.77.2)
|
vite: 5.2.11(@types/node@20.12.12)(sass@1.77.2)(terser@5.31.0)
|
||||||
vue: 3.4.27(typescript@5.4.5)
|
vue: 3.4.27(typescript@5.4.5)
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
'@vitejs/plugin-vue@5.0.4(vite@5.2.11(@types/node@20.12.12)(sass@1.77.2))(vue@3.4.27(typescript@5.4.5))':
|
'@vitejs/plugin-vue@5.0.4(vite@5.2.11(@types/node@20.12.12)(sass@1.77.2)(terser@5.31.0))(vue@3.4.27(typescript@5.4.5))':
|
||||||
dependencies:
|
dependencies:
|
||||||
vite: 5.2.11(@types/node@20.12.12)(sass@1.77.2)
|
vite: 5.2.11(@types/node@20.12.12)(sass@1.77.2)(terser@5.31.0)
|
||||||
vue: 3.4.27(typescript@5.4.5)
|
vue: 3.4.27(typescript@5.4.5)
|
||||||
|
|
||||||
'@volar/language-core@1.11.1':
|
'@volar/language-core@1.11.1':
|
||||||
|
@ -8180,6 +8199,8 @@ snapshots:
|
||||||
|
|
||||||
commander@12.1.0: {}
|
commander@12.1.0: {}
|
||||||
|
|
||||||
|
commander@2.20.3: {}
|
||||||
|
|
||||||
commander@4.1.1: {}
|
commander@4.1.1: {}
|
||||||
|
|
||||||
commander@7.2.0: {}
|
commander@7.2.0: {}
|
||||||
|
@ -8281,7 +8302,7 @@ snapshots:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/node': 20.5.1
|
'@types/node': 20.5.1
|
||||||
cosmiconfig: 8.3.6(typescript@5.4.5)
|
cosmiconfig: 8.3.6(typescript@5.4.5)
|
||||||
ts-node: 10.9.2(@types/node@20.5.1)(typescript@5.4.5)
|
ts-node: 10.9.2(@types/node@20.12.12)(typescript@5.4.5)
|
||||||
typescript: 5.4.5
|
typescript: 5.4.5
|
||||||
|
|
||||||
cosmiconfig-typescript-loader@5.0.0(@types/node@20.12.12)(cosmiconfig@9.0.0(typescript@5.4.5))(typescript@5.4.5):
|
cosmiconfig-typescript-loader@5.0.0(@types/node@20.12.12)(cosmiconfig@9.0.0(typescript@5.4.5))(typescript@5.4.5):
|
||||||
|
@ -9699,7 +9720,7 @@ snapshots:
|
||||||
slash: 3.0.0
|
slash: 3.0.0
|
||||||
strip-json-comments: 3.1.1
|
strip-json-comments: 3.1.1
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
ts-node: 10.9.2(@types/node@20.5.1)(typescript@5.4.5)
|
ts-node: 10.9.2(@types/node@20.12.12)(typescript@5.4.5)
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- bufferutil
|
- bufferutil
|
||||||
- canvas
|
- canvas
|
||||||
|
@ -10786,7 +10807,7 @@ snapshots:
|
||||||
yaml: 2.4.2
|
yaml: 2.4.2
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
postcss: 8.4.38
|
postcss: 8.4.38
|
||||||
ts-node: 10.9.2(@types/node@20.5.1)(typescript@5.4.5)
|
ts-node: 10.9.2(@types/node@20.12.12)(typescript@5.4.5)
|
||||||
|
|
||||||
postcss-media-query-parser@0.2.3: {}
|
postcss-media-query-parser@0.2.3: {}
|
||||||
|
|
||||||
|
@ -11721,6 +11742,13 @@ snapshots:
|
||||||
ansi-escapes: 4.3.2
|
ansi-escapes: 4.3.2
|
||||||
supports-hyperlinks: 2.3.0
|
supports-hyperlinks: 2.3.0
|
||||||
|
|
||||||
|
terser@5.31.0:
|
||||||
|
dependencies:
|
||||||
|
'@jridgewell/source-map': 0.3.6
|
||||||
|
acorn: 8.11.3
|
||||||
|
commander: 2.20.3
|
||||||
|
source-map-support: 0.5.21
|
||||||
|
|
||||||
test-exclude@6.0.0:
|
test-exclude@6.0.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@istanbuljs/schema': 0.1.3
|
'@istanbuljs/schema': 0.1.3
|
||||||
|
@ -11796,14 +11824,14 @@ snapshots:
|
||||||
|
|
||||||
ts-interface-checker@0.1.13: {}
|
ts-interface-checker@0.1.13: {}
|
||||||
|
|
||||||
ts-node@10.9.2(@types/node@20.5.1)(typescript@5.4.5):
|
ts-node@10.9.2(@types/node@20.12.12)(typescript@5.4.5):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@cspotcode/source-map-support': 0.8.1
|
'@cspotcode/source-map-support': 0.8.1
|
||||||
'@tsconfig/node10': 1.0.11
|
'@tsconfig/node10': 1.0.11
|
||||||
'@tsconfig/node12': 1.0.11
|
'@tsconfig/node12': 1.0.11
|
||||||
'@tsconfig/node14': 1.0.3
|
'@tsconfig/node14': 1.0.3
|
||||||
'@tsconfig/node16': 1.0.4
|
'@tsconfig/node16': 1.0.4
|
||||||
'@types/node': 20.5.1
|
'@types/node': 20.12.12
|
||||||
acorn: 8.11.3
|
acorn: 8.11.3
|
||||||
acorn-walk: 8.3.2
|
acorn-walk: 8.3.2
|
||||||
arg: 4.1.3
|
arg: 4.1.3
|
||||||
|
@ -11964,12 +11992,12 @@ snapshots:
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- rollup
|
- rollup
|
||||||
|
|
||||||
vite-plugin-compression@0.5.1(vite@5.2.11(@types/node@20.12.12)(sass@1.77.2)):
|
vite-plugin-compression@0.5.1(vite@5.2.11(@types/node@20.12.12)(sass@1.77.2)(terser@5.31.0)):
|
||||||
dependencies:
|
dependencies:
|
||||||
chalk: 4.1.2
|
chalk: 4.1.2
|
||||||
debug: 4.3.4
|
debug: 4.3.4
|
||||||
fs-extra: 10.1.0
|
fs-extra: 10.1.0
|
||||||
vite: 5.2.11(@types/node@20.12.12)(sass@1.77.2)
|
vite: 5.2.11(@types/node@20.12.12)(sass@1.77.2)(terser@5.31.0)
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
|
@ -11990,7 +12018,7 @@ snapshots:
|
||||||
svgo: 3.3.2
|
svgo: 3.3.2
|
||||||
vue: 3.4.27(typescript@5.4.5)
|
vue: 3.4.27(typescript@5.4.5)
|
||||||
|
|
||||||
vite@5.2.11(@types/node@20.12.12)(sass@1.77.2):
|
vite@5.2.11(@types/node@20.12.12)(sass@1.77.2)(terser@5.31.0):
|
||||||
dependencies:
|
dependencies:
|
||||||
esbuild: 0.20.2
|
esbuild: 0.20.2
|
||||||
postcss: 8.4.38
|
postcss: 8.4.38
|
||||||
|
@ -11999,6 +12027,7 @@ snapshots:
|
||||||
'@types/node': 20.12.12
|
'@types/node': 20.12.12
|
||||||
fsevents: 2.3.3
|
fsevents: 2.3.3
|
||||||
sass: 1.77.2
|
sass: 1.77.2
|
||||||
|
terser: 5.31.0
|
||||||
|
|
||||||
vue-demi@0.14.7(vue@3.4.27(typescript@5.4.5)):
|
vue-demi@0.14.7(vue@3.4.27(typescript@5.4.5)):
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|
|
@ -1,20 +1,19 @@
|
||||||
import axios from "axios";
|
import axios from 'axios';
|
||||||
import type { App } from "vue";
|
import type { App } from 'vue';
|
||||||
|
|
||||||
let config: object = {};
|
let config: object = {};
|
||||||
const { VITE_PUBLIC_PATH } = import.meta.env;
|
|
||||||
|
|
||||||
const setConfig = (cfg?: unknown) => {
|
const setConfig = (cfg?: unknown) => {
|
||||||
config = Object.assign(config, cfg);
|
config = Object.assign(config, cfg);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getConfig = (key?: string): PlatformConfigs => {
|
const getConfig = (key?: string): PlatformConfigs => {
|
||||||
if (typeof key === "string") {
|
if (typeof key === 'string') {
|
||||||
const arr = key.split(".");
|
const arr = key.split('.');
|
||||||
if (arr && arr.length) {
|
if (arr && arr.length) {
|
||||||
let data = config;
|
let data = config;
|
||||||
arr.forEach(v => {
|
arr.forEach(v => {
|
||||||
if (data && typeof data[v] !== "undefined") {
|
if (data && typeof data[v] !== 'undefined') {
|
||||||
data = data[v];
|
data = data[v];
|
||||||
} else {
|
} else {
|
||||||
data = null;
|
data = null;
|
||||||
|
@ -30,13 +29,13 @@ const getConfig = (key?: string): PlatformConfigs => {
|
||||||
export const getPlatformConfig = async (app: App): Promise<undefined> => {
|
export const getPlatformConfig = async (app: App): Promise<undefined> => {
|
||||||
app.config.globalProperties.$config = getConfig();
|
app.config.globalProperties.$config = getConfig();
|
||||||
return axios({
|
return axios({
|
||||||
method: "get",
|
method: 'get',
|
||||||
url: `${VITE_PUBLIC_PATH}platform-config.json`
|
url: `platform-config.json`,
|
||||||
})
|
})
|
||||||
.then(({ data: config }) => {
|
.then(({ data: config }) => {
|
||||||
let $config = app.config.globalProperties.$config;
|
let $config = app.config.globalProperties.$config;
|
||||||
// 自动注入系统配置
|
// 自动注入系统配置
|
||||||
if (app && $config && typeof config === "object") {
|
if (app && $config && typeof config === 'object') {
|
||||||
$config = Object.assign($config, config);
|
$config = Object.assign($config, config);
|
||||||
app.config.globalProperties.$config = $config;
|
app.config.globalProperties.$config = $config;
|
||||||
// 设置全局配置
|
// 设置全局配置
|
||||||
|
@ -45,7 +44,7 @@ export const getPlatformConfig = async (app: App): Promise<undefined> => {
|
||||||
return $config;
|
return $config;
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
throw "请在public文件夹下添加platform-config.json配置文件";
|
throw '请在public文件夹下添加platform-config.json配置文件';
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import type { ECharts } from "echarts";
|
import type { ECharts } from 'echarts';
|
||||||
import type { TableColumns } from "@pureadmin/table";
|
import type { TableColumns } from '@pureadmin/table';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 全局类型声明,无需引入直接在 `.vue` 、`.ts` 、`.tsx` 文件使用即可获得类型提示
|
* 全局类型声明,无需引入直接在 `.vue` 、`.ts` 、`.tsx` 文件使用即可获得类型提示
|
||||||
|
@ -50,19 +50,17 @@ declare global {
|
||||||
/**
|
/**
|
||||||
* 打包压缩格式的类型声明
|
* 打包压缩格式的类型声明
|
||||||
*/
|
*/
|
||||||
type ViteCompression = "none" | "gzip" | "brotli" | "both" | "gzip-clear" | "brotli-clear" | "both-clear";
|
type ViteCompression = 'none' | 'gzip' | 'brotli' | 'both' | 'gzip-clear' | 'brotli-clear' | 'both-clear';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 全局自定义环境变量的类型声明
|
* TODO 全局自定义环境变量的类型声明
|
||||||
* @see {@link https://pure-admin.github.io/pure-admin-doc/pages/config/#%E5%85%B7%E4%BD%93%E9%85%8D%E7%BD%AE}
|
* @see {@link https://pure-admin.github.io/pure-admin-doc/pages/config/#%E5%85%B7%E4%BD%93%E9%85%8D%E7%BD%AE}
|
||||||
*/
|
*/
|
||||||
interface ViteEnv {
|
interface ViteEnv {
|
||||||
VITE_PORT: number;
|
VITE_PORT: number; // 启动端口号
|
||||||
VITE_PUBLIC_PATH: string;
|
VITE_APP_URL: string; // 跨域代理地址
|
||||||
VITE_ROUTER_HISTORY: string;
|
|
||||||
VITE_CDN: boolean;
|
|
||||||
VITE_HIDE_HOME: string;
|
|
||||||
VITE_COMPRESSION: ViteCompression;
|
VITE_COMPRESSION: ViteCompression;
|
||||||
|
VITE_CDN: boolean; // 是否启用CDN
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,52 +1,28 @@
|
||||||
import { getPluginsList } from './build/plugins';
|
import { getPluginsList } from './build/plugins';
|
||||||
import { include, exclude } from './build/optimize';
|
import { exclude, include } from './build/optimize';
|
||||||
import { type UserConfigExport, type ConfigEnv, loadEnv } from 'vite';
|
import { type ConfigEnv, loadEnv, type UserConfigExport } from 'vite';
|
||||||
import { root, alias, wrapperEnv, pathResolve, __APP_INFO__ } from './build/utils';
|
import { __APP_INFO__, alias, root, wrapperEnv } from './build/utils';
|
||||||
|
import { buildEnvironment } from './build/buildEnv';
|
||||||
|
import { serverOptions } from './build/server'; // Vite中文文档:https://cn.vitejs.dev/guide/build#browser-compatibility
|
||||||
|
|
||||||
|
// Vite中文文档:https://cn.vitejs.dev/guide/build#browser-compatibility
|
||||||
export default ({ mode }: ConfigEnv): UserConfigExport => {
|
export default ({ mode }: ConfigEnv): UserConfigExport => {
|
||||||
const { VITE_CDN, VITE_PORT, VITE_COMPRESSION, VITE_PUBLIC_PATH } = wrapperEnv(loadEnv(mode, root));
|
const { VITE_CDN, VITE_COMPRESSION } = wrapperEnv(loadEnv(mode, root));
|
||||||
return {
|
return {
|
||||||
base: VITE_PUBLIC_PATH,
|
|
||||||
root,
|
root,
|
||||||
resolve: {
|
resolve: { alias },
|
||||||
alias,
|
|
||||||
},
|
|
||||||
// 服务端渲染
|
// 服务端渲染
|
||||||
server: {
|
server: serverOptions(mode),
|
||||||
// 端口号
|
// 插件相关
|
||||||
port: VITE_PORT,
|
|
||||||
host: '0.0.0.0',
|
|
||||||
// 本地跨域代理 https://cn.vitejs.dev/config/server-options.html#server-proxy
|
|
||||||
proxy: {},
|
|
||||||
// 预热文件以提前转换和缓存结果,降低启动期间的初始页面加载时长并防止转换瀑布
|
|
||||||
warmup: {
|
|
||||||
clientFiles: ['./index.html', './src/{views,components}/*'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
plugins: getPluginsList(VITE_CDN, VITE_COMPRESSION),
|
plugins: getPluginsList(VITE_CDN, VITE_COMPRESSION),
|
||||||
// https://cn.vitejs.dev/config/dep-optimization-options.html#dep-optimization-options
|
optimizeDeps: { include, exclude },
|
||||||
optimizeDeps: {
|
esbuild: {
|
||||||
include,
|
pure: ['console.log', 'debugger'],
|
||||||
exclude,
|
jsxFactory: 'h',
|
||||||
},
|
jsxFragment: 'Fragment',
|
||||||
build: {
|
jsxInject: "import { h } from 'vue';",
|
||||||
// https://cn.vitejs.dev/guide/build.html#browser-compatibility
|
|
||||||
target: 'es2015',
|
|
||||||
sourcemap: false,
|
|
||||||
// 消除打包大小超过500kb警告
|
|
||||||
chunkSizeWarningLimit: 4000,
|
|
||||||
rollupOptions: {
|
|
||||||
input: {
|
|
||||||
index: pathResolve('./index.html', import.meta.url),
|
|
||||||
},
|
|
||||||
// 静态资源分类打包
|
|
||||||
output: {
|
|
||||||
chunkFileNames: 'static/js/[name]-[hash].js',
|
|
||||||
entryFileNames: 'static/js/[name]-[hash].js',
|
|
||||||
assetFileNames: 'static/[ext]/[name]-[hash].[ext]',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
build: buildEnvironment(),
|
||||||
define: {
|
define: {
|
||||||
__INTLIFY_PROD_DEVTOOLS__: false,
|
__INTLIFY_PROD_DEVTOOLS__: false,
|
||||||
__APP_INFO__: JSON.stringify(__APP_INFO__),
|
__APP_INFO__: JSON.stringify(__APP_INFO__),
|
||||||
|
|
Loading…
Reference in New Issue