UNPKG

vite-pwa

Version:

This package helps you to cache your files with service worker.

22 lines (21 loc) 938 B
import path from 'path'; import * as root from './root.js'; import vitePwa from './vitePwa.js'; export default (conf) => { if (process.env.NODE_ENV !== 'production') return { name: root.name }; const config = Object.assign(Object.assign({}, root.defaultConfig), conf); config.mapDest = path.join('/', config.mapDest); config.swDest = path.join('/', config.swDest + '.js'); config.swRegisterDest = path.join('/', config.swRegisterDest + '.js'); const extraConfg = { swDest: path.relative('/', config.swDest), swRegisterDest: path.relative('/', config.swRegisterDest), mapAllDest: path.relative('/', config.mapDest + '.all.json'), mapBuildDest: path.relative('/', config.mapDest + '.build.json'), }; if (config.preCacheSw) { config.preCacheFiles.push(config.swDest, config.swRegisterDest); } return vitePwa(config, extraConfg); };