Steven Fukase 4 лет назад
Родитель
Сommit
5b762b17ee

+ 0 - 31
packages/app/bin/cdn/cdn-resources-downloader.ts

@@ -19,9 +19,6 @@ export default class CdnResourcesDownloader {
     const cdnScriptResources: CdnResource[] = cdnManifests.js.map((manifest: CdnManifest) => {
       return { manifest, outDir: cdnLocalScriptRoot };
     });
-    // const cdnGzResources: CdnResource[] = cdnManifests.gz.map((manifest: CdnManifest) => {
-    //   return { manifest, outDir: cdnLocalScriptRoot };
-    // });
     const cdnStyleResources: CdnResource[] = cdnManifests.style.map((manifest) => {
       return { manifest, outDir: cdnLocalStyleRoot };
     });
@@ -34,7 +31,6 @@ export default class CdnResourcesDownloader {
 
     return Promise.all([
       this.downloadScripts(cdnScriptResources),
-      // this.downloadGz(cdnGzResources),
       this.downloadStyles(cdnStyleResources, dlStylesOptions),
     ]);
   }
@@ -65,33 +61,6 @@ export default class CdnResourcesDownloader {
     return Promise.all(promises);
   }
 
-
-  // /**
-  //  * Download gz files from CDN
-  //  * @param cdnResources JavaScript resource data
-  //  * @param options
-  //  */
-  // private async downloadGz(cdnResources: CdnResource[], options?: any): Promise<any> {
-  //   logger.debug('Downloading scripts', cdnResources);
-
-  //   const opts = Object.assign({}, options);
-  //   const ext = opts.ext || 'gz';
-
-  //   const promises = cdnResources.map((cdnResource) => {
-  //     const { manifest } = cdnResource;
-
-  //     logger.info(`Processing CdnResource '${manifest.name}'`);
-
-  //     return downloadTo(
-  //       manifest.url,
-  //       cdnResource.outDir,
-  //       `${manifest.name}.${ext}`,
-  //     );
-  //   });
-
-  //   return Promise.all(promises);
-  // }
-
   /**
    * Download style sheet file from CDN
    *  Assets in CSS is also downloaded

+ 14 - 12
packages/app/resource/cdn-manifests.js

@@ -88,85 +88,87 @@ module.exports = {
         integrity: '',
       },
     },
+  ],
+  gz: [
     {
-      name: 'base.dat',
+      name: 'base',
       url: 'https://cdn.jsdelivr.net/npm/kuromoji@0.1.2/dict/base.dat.gz,',
       args: {
         integrity: '',
       },
     },
     {
-      name: 'cc.dat',
+      name: 'cc',
       url: 'https://cdn.jsdelivr.net/npm/kuromoji@0.1.2/dict/cc.dat.gz,',
       args: {
         integrity: '',
       },
     },
     {
-      name: 'check.dat',
+      name: 'check',
       url: 'https://cdn.jsdelivr.net/npm/kuromoji@0.1.2/dict/check.dat.gz,',
       args: {
         integrity: '',
       },
     },
     {
-      name: 'tid_map.dat',
+      name: 'tid_map',
       url: 'https://cdn.jsdelivr.net/npm/kuromoji@0.1.2/dict/tid_map.dat.gz,',
       args: {
         integrity: '',
       },
     },
     {
-      name: 'tid_pos.dat',
+      name: 'tid_pos',
       url: 'https://cdn.jsdelivr.net/npm/kuromoji@0.1.2/dict/tid_pos.dat.gz,',
       args: {
         integrity: '',
       },
     },
     {
-      name: 'tid.dat',
+      name: 'tid',
       url: 'https://cdn.jsdelivr.net/npm/kuromoji@0.1.2/dict/tid.dat.gz,',
       args: {
         integrity: '',
       },
     },
     {
-      name: 'unk_char.dat',
+      name: 'unk_char',
       url: 'https://cdn.jsdelivr.net/npm/kuromoji@0.1.2/dict/unk_char.dat.gz,',
       args: {
         integrity: '',
       },
     },
     {
-      name: 'unk_compat.dat',
+      name: 'unk_compat',
       url: 'https://cdn.jsdelivr.net/npm/kuromoji@0.1.2/dict/unk_compat.dat.gz,',
       args: {
         integrity: '',
       },
     },
     {
-      name: 'unk_invoke.dat',
+      name: 'unk_invoke',
       url: 'https://cdn.jsdelivr.net/npm/kuromoji@0.1.2/dict/unk_invoke.dat.gz,',
       args: {
         integrity: '',
       },
     },
     {
-      name: 'unk_map.dat',
+      name: 'unk_map',
       url: 'https://cdn.jsdelivr.net/npm/kuromoji@0.1.2/dict/unk_map.dat.gz,',
       args: {
         integrity: '',
       },
     },
     {
-      name: 'unk_pos.dat',
+      name: 'unk_pos',
       url: 'https://cdn.jsdelivr.net/npm/kuromoji@0.1.2/dict/unk_pos.dat.gz,',
       args: {
         integrity: '',
       },
     },
     {
-      name: 'unk.dat',
+      name: 'unk',
       url: 'https://cdn.jsdelivr.net/npm/kuromoji@0.1.2/dict/unk.dat.gz',
       args: {
         integrity: '',

+ 11 - 0
packages/app/src/services/cdn-resources-service.js

@@ -57,6 +57,16 @@ class CdnResourcesService {
       const outDir = resolveFromRoot(cdnLocalScriptRoot);
       return new CdnResource(manifest.name, manifest.url, outDir);
     });
+
+    const cdnGzResources = this.cdnManifests.gz.map((manifest) => {
+      const outDir = resolveFromRoot(cdnLocalScriptRoot);
+      return new CdnResource(manifest.name, manifest.url, outDir);
+    });
+
+    const gzExtensionOptions = {
+      ext: 'gz',
+    };
+
     const cdnStyleResources = this.cdnManifests.style.map((manifest) => {
       const outDir = resolveFromRoot(cdnLocalStyleRoot);
       return new CdnResource(manifest.name, manifest.url, outDir);
@@ -70,6 +80,7 @@ class CdnResourcesService {
 
     return Promise.all([
       cdnResourceDownloader.downloadScripts(cdnScriptResources),
+      cdnResourceDownloader.downloadScripts(cdnGzResources, gzExtensionOptions),
       cdnResourceDownloader.downloadStyles(cdnStyleResources, dlStylesOptions),
     ]);
   }