You've already forked SmartisanNote.Remake
优化 编译策略调整
This commit is contained in:
@@ -1,20 +1,15 @@
|
|||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from 'vite'
|
||||||
import vue from '@vitejs/plugin-vue'
|
import vue from '@vitejs/plugin-vue'
|
||||||
import { VitePWA } from 'vite-plugin-pwa'
|
import { VitePWA } from 'vite-plugin-pwa'
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig(({ mode }) => {
|
export default defineConfig(({ mode }) => {
|
||||||
const isPwaMode = mode === 'pwa'
|
const isPwaMode = mode === 'pwa'
|
||||||
|
|
||||||
const plugins = [vue()]
|
const plugins = [vue()]
|
||||||
|
|
||||||
// 只在PWA模式下添加PWA插件
|
// 只在PWA模式下添加PWA插件
|
||||||
if (isPwaMode) {
|
if (isPwaMode) {
|
||||||
plugins.push(
|
plugins.push(
|
||||||
VitePWA({
|
VitePWA({
|
||||||
strategies: 'injectManifest',
|
strategies: 'generateSW',
|
||||||
srcDir: 'src',
|
|
||||||
filename: 'sw.js',
|
|
||||||
registerType: 'autoUpdate',
|
registerType: 'autoUpdate',
|
||||||
devOptions: {
|
devOptions: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
@@ -41,13 +36,23 @@ export default defineConfig(({ mode }) => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
injectManifest: {
|
workbox: {
|
||||||
globPatterns: ['**/*.{js,css,html,wasm,png,jpg,jpeg,svg,ico}'],
|
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 {
|
return {
|
||||||
plugins,
|
plugins,
|
||||||
resolve: {
|
resolve: {
|
||||||
|
|||||||
Reference in New Issue
Block a user