UNPKG

sw-builder

Version:

The sw-builder package automates the creation of your Application's Service Worker, which pre-caches your build. This leads to a better overall performance and enables users to access your PWA without an Internet connection.

39 lines (38 loc) 1.69 kB
import { IBaseConfig } from '../shared/types.js'; declare const CACHE_NAME_CHARACTERS = "abcdefghijklmnopqrstuvwxyz0123456789"; declare const CACHE_NAME_LENGTH: number; declare const OUTPUT_NAME: string; /** * Reads, validates and returns the configuration file. * @param configPath * @returns IBaseConfig * @throws * - NOT_A_FILE: if the path is not recognized by the OS as a file or if it doesn't exist * - FILE_CONTENT_IS_EMPTY_OR_INVALID: if the content of the file is empty or invalid * - FILE_CONTENT_IS_EMPTY_OR_INVALID: if the file's JSON content cannot be parsed * - INVALID_CONFIG_VALUE: if any of the essential config values is invalid */ declare const readConfigFile: (configPath: string) => IBaseConfig; /** * Generates a randomly generated name to be used for the CacheStorage * @returns string */ declare const generateCacheName: () => string; /** * Puts the list of all the assets that must be cached based on the include and exclude lists. * If there are no items to precache, an empty list will be returned. * @param outDir * @param includeToPrecache * @param excludeFilesFromPrecache * @returns string[] * @throws * - NOT_A_PATH_ELEMENT: if the provided path doesn't exist or is not a valid path element */ declare const buildPrecacheAssetPaths: (outDir: string, includeToPrecache: string[], excludeFilesFromPrecache: string[]) => string[]; /** * Builds the binary's output build based on the config's outDir. * @param outDir * @returns string */ declare const buildOutputPath: (outDir: string) => string; export { CACHE_NAME_CHARACTERS, CACHE_NAME_LENGTH, OUTPUT_NAME, readConfigFile, generateCacheName, buildPrecacheAssetPaths, buildOutputPath, };