mirror of
https://github.com/cotes2020/jekyll-theme-chirpy.git
synced 2025-12-18 21:53:26 +00:00
feat: add pwa.cache.* option to precisely control caching (#1501)
This commit is contained in:
@@ -3,21 +3,29 @@ import terser from '@rollup/plugin-terser';
|
||||
import license from 'rollup-plugin-license';
|
||||
import path from 'path';
|
||||
|
||||
const JS_SRC = '_javascript';
|
||||
const JS_DIST = 'assets/js/dist';
|
||||
const SRC_DEFAULT = '_javascript';
|
||||
const DIST_DEFAULT = 'assets/js/dist';
|
||||
const isProd = process.env.NODE_ENV === 'production';
|
||||
|
||||
function build(filename) {
|
||||
function build(filename, opts) {
|
||||
let src = SRC_DEFAULT;
|
||||
let dist = DIST_DEFAULT;
|
||||
|
||||
if (typeof opts !== 'undefined') {
|
||||
src = opts.src || src;
|
||||
dist = opts.dist || dist;
|
||||
}
|
||||
|
||||
return {
|
||||
input: [`${JS_SRC}/${filename}.js`],
|
||||
input: [`${src}/${filename}.js`],
|
||||
output: {
|
||||
file: `${JS_DIST}/${filename}.min.js`,
|
||||
file: `${dist}/${filename}.min.js`,
|
||||
format: 'iife',
|
||||
name: 'Chirpy',
|
||||
sourcemap: !isProd
|
||||
},
|
||||
watch: {
|
||||
include: `${JS_SRC}/**`
|
||||
include: `${src}/**`
|
||||
},
|
||||
plugins: [
|
||||
babel({
|
||||
@@ -28,7 +36,7 @@ function build(filename) {
|
||||
license({
|
||||
banner: {
|
||||
commentStyle: 'ignored',
|
||||
content: { file: path.join(__dirname, JS_SRC, '_copyright') }
|
||||
content: { file: path.join(__dirname, SRC_DEFAULT, '_copyright') }
|
||||
}
|
||||
}),
|
||||
isProd && terser()
|
||||
@@ -42,5 +50,7 @@ export default [
|
||||
build('categories'),
|
||||
build('page'),
|
||||
build('post'),
|
||||
build('misc')
|
||||
build('misc'),
|
||||
build('app', { src: `${SRC_DEFAULT}/pwa` }),
|
||||
build('sw', { src: `${SRC_DEFAULT}/pwa`, dist: '.' })
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user