source: frontend/node_modules/workbox-build/src/lib/cdn-utils.ts

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/*
2 Copyright 2021 Google LLC
3
4 Use of this source code is governed by an MIT-style
5 license that can be found in the LICENSE file or at
6 https://opensource.org/licenses/MIT.
7*/
8
9import {ok} from 'assert';
10
11import {BuildType, WorkboxPackageJSON} from '../types';
12import {errors} from './errors';
13import * as cdn from '../cdn-details.json';
14
15function getVersionedURL(): string {
16 return `${getCDNPrefix()}/${cdn.latestVersion}`;
17}
18
19function getCDNPrefix() {
20 return `${cdn.origin}/${cdn.bucketName}/${cdn.releasesDir}`;
21}
22
23export function getModuleURL(moduleName: string, buildType: BuildType): string {
24 ok(moduleName, errors['no-module-name']);
25
26 if (buildType) {
27 // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
28 const pkgJson: WorkboxPackageJSON = require(`${moduleName}/package.json`);
29 if (buildType === 'dev' && pkgJson.workbox && pkgJson.workbox.prodOnly) {
30 // This is not due to a public-facing exception, so just throw an Error(),
31 // without creating an entry in errors.js.
32 throw Error(`The 'dev' build of ${moduleName} is not available.`);
33 }
34 return `${getVersionedURL()}/${moduleName}.${buildType.slice(0, 4)}.js`;
35 }
36 return `${getVersionedURL()}/${moduleName}.js`;
37}
Note: See TracBrowser for help on using the repository browser.