vite-plugin-pwa报错:Configure “workbox.maximumFileSizeToCacheInBytes“ to change the limit

(!) Some chunks are larger than 500 kB after minification. Consider:
- Using dynamic import() to code-split the application
- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks
- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
✓ built in 52.65s
error during build:
Error:
  Configure "workbox.maximumFileSizeToCacheInBytes" to change the limit: the default value is 2 MiB.
  Check https://vite-pwa-org.netlify.app/guide/faq.html#missing-assets-from-sw-precache-manifest for more information.
  Assets exceeding the limit:
  - assets/toggleHighContrast-DkQyWRYP.js is 3.33 MB, and won't be precached.

    at logWorkboxResult (file:///D:/source/m-apps/m-demo1-admin/node_modules/vite-plugin-pwa/dist/chunk-G4TAN34B.js:44:13)
    at generateServiceWorker (file:///D:/source/m-apps/m-demo1-admin/node_modules/vite-plugin-pwa/dist/index.js:209:3)
    at async _generateSW (file:///D:/source/m-apps/m-demo1-admin/node_modules/vite-plugin-pwa/dist/index.js:234:5)
    at async Object.handler (file:///D:/source/m-apps/m-demo1-admin/node_modules/vite-plugin-pwa/dist/index.js:425:13)
    at async PluginDriver.hookParallel (file:///D:/source/m-apps/m-demo1-admin/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:19696:17)
    at async Object.close (file:///D:/source/m-apps/m-demo1-admin/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:20631:13)
    at async build (file:///D:/source/m-apps/m-demo1-admin/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:67497:13)
    at async CAC. (file:///D:/source/m-apps/m-demo1-admin/node_modules/vite/dist/node/cli.js:842:9)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: "build-only" exited with 1.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

解决方案:

vite-plugin-pwa报错:Configure “workbox.maximumFileSizeToCacheInBytes“ to change the limit_第1张图片

vue.config.ts:

import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { visualizer } from 'rollup-plugin-visualizer'
import VueDevTools from 'vite-plugin-vue-devtools'
import { VitePWA } from 'vite-plugin-pwa'

// https://vitejs.dev/config/
export default defineConfig({
  server: {
    port: 3003,
    proxy: {
      '/api': {
        target: 'http://localhost:85',
        changeOrigin: true,
        rewrite: (path) => {
          console.log(path)
          return path.replace(/^\/api/, '/api')
        }
      }
    }
  },
  plugins: [
    vue(),
    VitePWA({
      registerType: 'autoUpdate',
      manifest: {
        name: 'demo',
        short_name: 'xu',
        theme_color: '#ffffff'
      },
      workbox: {
        maximumFileSizeToCacheInBytes: 10 * 1024 * 1024
      }
    })
    //VueDevTools(),
    //visualizer()
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})

人工智能学习网站

https://chat.xutongbao.top

 

你可能感兴趣的:(前端,javascript,开发语言)