You've already forked SmartisanNote.Remake
优化 编译策略调整
This commit is contained in:
@@ -1,20 +1,15 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import { VitePWA } from 'vite-plugin-pwa'
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig(({ mode }) => {
|
||||
const isPwaMode = mode === 'pwa'
|
||||
|
||||
const plugins = [vue()]
|
||||
|
||||
// 只在PWA模式下添加PWA插件
|
||||
if (isPwaMode) {
|
||||
plugins.push(
|
||||
VitePWA({
|
||||
strategies: 'injectManifest',
|
||||
srcDir: 'src',
|
||||
filename: 'sw.js',
|
||||
strategies: 'generateSW',
|
||||
registerType: 'autoUpdate',
|
||||
devOptions: {
|
||||
enabled: false,
|
||||
@@ -41,13 +36,23 @@ export default defineConfig(({ mode }) => {
|
||||
},
|
||||
],
|
||||
},
|
||||
injectManifest: {
|
||||
globPatterns: ['**/*.{js,css,html,wasm,png,jpg,jpeg,svg,ico}'],
|
||||
workbox: {
|
||||
globPatterns: ['**/*.{js,css,html,ico,png,jpg,jpeg,svg,woff,woff2,ttf,eot}'],
|
||||
// 预缓存我们指定的静态资源
|
||||
additionalManifestEntries: [
|
||||
{ url: '/', revision: null },
|
||||
{ url: '/index.html', revision: null },
|
||||
{ url: '/icons/icon-192.png', revision: null },
|
||||
{ url: '/icons/icon-512.png', revision: null },
|
||||
// 添加更多需要预缓存的静态资源
|
||||
{ url: '/assets/icons/drawable-xxhdpi/note_background.png', revision: null },
|
||||
{ url: '/assets/icons/drawable-xxhdpi/note_setting_bg.png', revision: null },
|
||||
{ url: '/assets/icons/drawable-xxhdpi/action_bar_default.png', revision: null },
|
||||
],
|
||||
},
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
return {
|
||||
plugins,
|
||||
resolve: {
|
||||
|
||||
Reference in New Issue
Block a user