You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by wa...@apache.org on 2022/04/23 13:46:28 UTC

[echarts-website] branch pwa updated: fix(pwa): improve pwa config

This is an automated email from the ASF dual-hosted git repository.

wangzx pushed a commit to branch pwa
in repository https://gitbox.apache.org/repos/asf/echarts-website.git


The following commit(s) were added to refs/heads/pwa by this push:
     new f2ae8ccd fix(pwa): improve pwa config
f2ae8ccd is described below

commit f2ae8ccd9f82e72bbee8af76462330294cc38267
Author: plainheart <yh...@all-my-life.cn>
AuthorDate: Sat Apr 23 21:45:59 2022 +0800

    fix(pwa): improve pwa config
---
 .scripts/pwa/vite.config.js | 32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)

diff --git a/.scripts/pwa/vite.config.js b/.scripts/pwa/vite.config.js
index e3dcbd47..7d51498a 100644
--- a/.scripts/pwa/vite.config.js
+++ b/.scripts/pwa/vite.config.js
@@ -24,11 +24,14 @@ module.exports = defineConfig({
         globIgnores: [
           '**\/\.*\/**\/*',
           '**\/node_modules\/**\/*',
+          '**\/examples\/**\/view\.html',
           'v4\/**\/*',
           'pwa\.js',
           'pwa-*\.js',
           'workbox-*\.js'
         ],
+        // ignoreURLParametersMatching: true,
+        offlineGoogleAnalytics: false,
         runtimeCaching: [
           {
             urlPattern: /^https:\/\/fonts\.(?:googleapis|gstatic)\.com\/.*/i,
@@ -46,9 +49,25 @@ module.exports = defineConfig({
             },
           },
           {
-            urlPattern: '/^https:\/\/.*\.?(?:hm\.baidu|google-analytics).*/i',
+            urlPattern: /^https:\/\/.*\.?(?:hm\.baidu|google-analytics|googletagmanager).*/i,
             handler: 'NetworkOnly'
           },
+          {
+            urlPattern: /^https:\/\/.*\.(?:jsdelivr|unpkg)(?:.*\/gh\/apache\/).*/i,
+            handler: 'StaleWhileRevalidate',
+            options: {
+              cacheName: 'cdn-apache-assets',
+              expiration: {
+                // PENDING not limit our apache repositories?
+                // maxEntries: 128,
+                maxAgeSeconds: 7 * 24 * 60 * 60, // 7 days
+              },
+              fetchOptions: {
+                mode: 'cors',
+                credentials: 'omit'
+              }
+            },
+          },
           {
             urlPattern: /^https:\/\/.*\.(?:jsdelivr|unpkg).*/i,
             handler: 'CacheFirst',
@@ -56,7 +75,7 @@ module.exports = defineConfig({
               cacheName: 'cdn-assets',
               expiration: {
                 maxEntries: 128,
-                maxAgeSeconds: 7 * 24 * 60 * 60, // 7 days
+                maxAgeSeconds: 30 * 24 * 60 * 60, // 30 days
               },
               fetchOptions: {
                 mode: 'cors',
@@ -70,7 +89,7 @@ module.exports = defineConfig({
             options: {
               cacheName: 'static-font-assets',
               expiration: {
-                maxEntries: 4,
+                maxEntries: 8,
                 maxAgeSeconds: 30 * 24 * 60 * 60, // 30 days
               }
             },
@@ -92,7 +111,7 @@ module.exports = defineConfig({
             options: {
               cacheName: 'static-js-assets',
               expiration: {
-                maxEntries: 32,
+                maxEntries: 64,
                 maxAgeSeconds: 24 * 60 * 60, // 24 hours
               },
             },
@@ -103,7 +122,7 @@ module.exports = defineConfig({
             options: {
               cacheName: 'static-style-assets',
               expiration: {
-                maxEntries: 32,
+                maxEntries: 64,
                 maxAgeSeconds: 24 * 60 * 60, // 24 hours
               },
             },
@@ -127,8 +146,9 @@ module.exports = defineConfig({
       name: 'replace-host',
       transform(code) {
         return {
-          // FIXME
+          // FIXME a bit tricky
           code: code
+            // inject by echarts-www
             .replace(/\/?__HOST__/g, '" + window.EC_WWW_HOST + "/')
             .replace(/__SCOPE__/g, '')
         }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org