mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-01-23 17:50:25 +08:00
feat: add pwa
This commit is contained in:
parent
173d402162
commit
a1b9902b97
@ -16,5 +16,8 @@ VITE_GLOB_API_URL=/api
|
||||
# Interface prefix
|
||||
VITE_GLOB_API_URL_PREFIX=
|
||||
|
||||
# use pwa
|
||||
VITE_USE_PWA = false
|
||||
|
||||
# TODO use Cdn
|
||||
VITE_USE_CDN = true
|
||||
|
@ -1,11 +1,16 @@
|
||||
## Wip
|
||||
|
||||
### ✨ Features
|
||||
|
||||
- 新增`pwa`功能,可在`.env.production`开启
|
||||
|
||||
### 🎫 Chores
|
||||
|
||||
- 升级 vite 版本为`v1.0.0.rc8`
|
||||
- vite.config.ts 内部 plugins 抽取
|
||||
- build 目录结构调整
|
||||
- 依赖更新
|
||||
- 文档更新
|
||||
|
||||
### ✨ Refactor
|
||||
|
||||
|
@ -80,6 +80,7 @@ export function isSiteMode(): boolean {
|
||||
export interface ViteEnv {
|
||||
VITE_PORT: number;
|
||||
VITE_USE_MOCK: boolean;
|
||||
VITE_USE_PWA: boolean;
|
||||
VITE_PUBLIC_PATH: string;
|
||||
VITE_PROXY: [string, string][];
|
||||
VITE_GLOB_APP_TITLE: string;
|
||||
|
@ -2,6 +2,7 @@ import type { Plugin as VitePlugin } from 'vite';
|
||||
import type { Plugin as rollupPlugin } from 'rollup';
|
||||
|
||||
import { createMockServer } from 'vite-plugin-mock';
|
||||
import { VitePWA } from 'vite-plugin-pwa';
|
||||
import ViteHtmlPlugin from 'vite-plugin-html';
|
||||
import PurgeIcons from 'vite-plugin-purge-icons';
|
||||
|
||||
@ -17,7 +18,7 @@ import { GLOB_CONFIG_FILE_NAME } from '../../constant';
|
||||
|
||||
// gen vite plugins
|
||||
export function createVitePlugins(viteEnv: ViteEnv) {
|
||||
const { VITE_USE_MOCK, VITE_GLOB_APP_TITLE, VITE_PUBLIC_PATH } = viteEnv;
|
||||
const { VITE_USE_MOCK, VITE_GLOB_APP_TITLE, VITE_PUBLIC_PATH, VITE_USE_PWA } = viteEnv;
|
||||
|
||||
const vitePlugins: VitePlugin[] = [];
|
||||
|
||||
@ -43,6 +44,13 @@ export function createVitePlugins(viteEnv: ViteEnv) {
|
||||
// vite-plugin-purge-icons
|
||||
vitePlugins.push(PurgeIcons());
|
||||
|
||||
if (isProdFn() && VITE_USE_PWA) {
|
||||
console.log('======================');
|
||||
console.log(VITE_USE_PWA);
|
||||
console.log('======================');
|
||||
vitePlugins.push(VitePWA());
|
||||
}
|
||||
|
||||
// vite-plugin-mock
|
||||
if (isDevFn() && VITE_USE_MOCK) {
|
||||
// open mock
|
||||
|
@ -91,6 +91,7 @@
|
||||
"vite-plugin-html": "^1.0.0-beta.2",
|
||||
"vite-plugin-mock": "^1.0.4",
|
||||
"vite-plugin-purge-icons": "^0.4.4",
|
||||
"vite-plugin-pwa": "^0.1.2",
|
||||
"vue-eslint-parser": "^7.1.1",
|
||||
"yargs": "^16.1.0"
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user