feat(jade): Add cacheBreaker for dev browser cache breaking
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import _ from 'lodash';
|
||||
import manifest from '../rev-manifest';
|
||||
|
||||
let chunkManifest;
|
||||
@@ -12,11 +13,11 @@ chunkManifest = Object.keys(chunkManifest).reduce((manifest, key) => {
|
||||
return manifest;
|
||||
}, {});
|
||||
|
||||
const __DEV__ = process.env.NODE_ENV !== 'production';
|
||||
const isDev = process.env.NODE_ENV !== 'production';
|
||||
const challengesRegex = /^(bonfire|waypoint|zipline|basejump|checkpoint):\s/i;
|
||||
|
||||
function rev(scopedPrepend, asset) {
|
||||
if (__DEV__) {
|
||||
if (isDev) {
|
||||
// do not use revision in dev mode
|
||||
return `${scopedPrepend}/${asset}`;
|
||||
}
|
||||
@@ -27,6 +28,11 @@ function removeOldTerms(str = '') {
|
||||
return str.replace(challengesRegex, '');
|
||||
}
|
||||
|
||||
const cacheBreaker = isDev ?
|
||||
// add cacheBreaker in dev instead of rev manifest
|
||||
asset => `${asset}?cacheBreaker=${Math.random()}` :
|
||||
_.identity;
|
||||
|
||||
export default function jadeHelpers() {
|
||||
return function jadeHelpersMiddleware(req, res, next) {
|
||||
res.locals.removeOldTerms = removeOldTerms;
|
||||
|
||||
Reference in New Issue
Block a user