Skip to content

Commit

Permalink
perf(build): 去除PWA功能
Browse files Browse the repository at this point in the history
  • Loading branch information
nihaojob committed Feb 6, 2024
1 parent 87eaf33 commit 9d61741
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 59 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"vite": "^4.2.1",
"vite-plugin-eslint": "^1.8.1",
"vite-plugin-html": "^3.2.0",
"vite-plugin-pwa": "^0.16.4",
"vite-plugin-vue-setup-extend-plus": "^0.1.0",
"vue-tsc": "^0.34.7"
},
Expand All @@ -69,4 +68,4 @@
"prettier --write"
]
}
}
}
21 changes: 14 additions & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,28 @@
"resolveJsonModule": true,
"isolatedModules": true,
"esModuleInterop": true,
"lib": ["esnext", "dom"],
"lib": [
"esnext",
"dom"
],
"skipLibCheck": true,
"paths": {
"@/*": ["./src/*"]
"@/*": [
"./src/*"
]
}
},
"files": [
"node_modules/vite-plugin-pwa/client.d.ts"
],
"files": [],
"include": [
"src/**/*.ts",
"src/**/*.d.ts",
"src/**/*.tsx",
"src/**/*.vue",
"typings/**/*.ts",
],
"references": [{ "path": "./tsconfig.node.json" }]
}
"references": [
{
"path": "./tsconfig.node.json"
}
]
}
52 changes: 2 additions & 50 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @version:
* @Author: June
* @Date: 2023-04-24 00:25:39
* @LastEditors: June
* @LastEditTime: 2024-01-06 22:15:15
* @LastEditors: 秦少卫
* @LastEditTime: 2024-02-06 15:40:37
*/
import { defineConfig, loadEnv } from 'vite';
import vue from '@vitejs/plugin-vue';
Expand All @@ -15,35 +15,6 @@ import vueSetupExtend from 'vite-plugin-vue-setup-extend-plus';
import autoImports from 'unplugin-auto-import/vite';
import { resolve } from 'path';
import autoprefixer from 'autoprefixer';
// import { VitePWA } from 'vite-plugin-pwa';

type CacheStrategy =
| 'CacheFirst'
| 'CacheOnly'
| 'NetworkFirst'
| 'NetworkOnly'
| 'StaleWhileRevalidate';
interface IgetCache {
name: string;
pattern: RegExp | string;
cacheDay?: number;
cacheType?: CacheStrategy;
}

const getCache = ({ name, pattern, cacheDay = 7, cacheType }: IgetCache) => ({
urlPattern: pattern,
handler: cacheType || 'CacheFirst',
options: {
cacheName: name,
expiration: {
maxEntries: 500,
maxAgeSeconds: 60 * 60 * 24 * cacheDay,
},
cacheableResponse: {
statuses: [200],
},
},
});

const config = ({ mode }) => {
const isProd = mode === 'production';
Expand All @@ -53,25 +24,6 @@ const config = ({ mode }) => {
base: isProd ? '/vue-fabric-editor/' : '/',
plugins: [
vue(),
// VitePWA({
// manifest: false,
// registerType: 'autoUpdate',
// workbox: {
// cacheId: APP_TITLE,
// runtimeCaching: [
// getCache({
// // js /css /ts静态资源缓存
// name: 'js-css-cache',
// pattern: /(.*?)\.(js|css|ts)/,
// }),
// getCache({
// // 图片缓存
// name: 'image-cache',
// pattern: /(.*?)\.(png|jpe?g|svg|gif|json|psd|ttf)/,
// }),
// ],
// },
// }),
autoImports({
imports: ['vue'],
dts: './typings/auto-imports.d.ts',
Expand Down

0 comments on commit 9d61741

Please sign in to comment.