From 5c19e0c699f6b54d9407239278de942623cd6497 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sun, 26 Sep 2021 10:53:27 +0200 Subject: [PATCH] remove only chunks older then 2 days, to allow UI to still load them and not require a reload / F5 --- rollup.config.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/rollup.config.js b/rollup.config.js index d36e92d712..8b9d0e246f 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -11,14 +11,21 @@ import path from 'path'; import babel from '@babel/core'; -import { readFileSync, readdirSync, statSync } from "fs"; -import rimraf from 'rimraf'; +import { readFileSync, readdirSync, statSync, unlinkSync } from "fs"; +//import rimraf from 'rimraf'; import { minify } from 'terser'; import resolve from '@rollup/plugin-node-resolve'; // Best practice: use this //rimraf.sync('./dist/'); -rimraf.sync('./chunks/'); +//rimraf.sync('./chunks/'); + +// remove only chunks older then 2 days, to allow UI to still load them and not require a reload / F5 +const rm_older = Date.now() - 48*3600000; +readdirSync('./chunks').forEach(name => { + const stat = statSync('./chunks/'+name); + if (stat.atimeMs < rm_older) unlinkSync('./chunks/'+name); +}); // Turn on minification const do_minify = true;