From 024d76ac9f1a44f80eef1daa6dec1a02e0780310 Mon Sep 17 00:00:00 2001 From: Boris Kubiak Date: Mon, 19 Feb 2018 08:49:42 +0100 Subject: [PATCH] Add cache-busting mechanism --- .travis.yml | 10 +++++++++- package.json | 3 +-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index dd8a67d..10a2c6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,15 @@ install: npm i script: - npm test - npm run build -- npm run clean + + # Remove unwanted files +- find . -maxdepth 1 -type f -not -name 'LICENSE' -not -name 'index.html' -not -name 'README.md' -delete && + rm -fr node_modules src dist/vanity.js + + #Cache busting +- COMMIT=$(git log --format='%h' -n 1) && + sed -i "s/index.js/index.$COMMIT.js/g" index.html && + mv dist/index.js dist/index.$COMMIT.js deploy: provider: pages diff --git a/package.json b/package.json index 9d4a9a0..a20419d 100644 --- a/package.json +++ b/package.json @@ -38,8 +38,7 @@ "scripts": { "test": "node ./node_modules/xo/cli.js", "dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot", - "build": "cross-env NODE_ENV=production webpack --progress --hide-modules", - "clean": "find . -maxdepth 1 -type f -not -name 'LICENSE' -not -name 'index.html' -not -name 'README.md' -delete && rm -fr node_modules src dist/vanity.js" + "build": "cross-env NODE_ENV=production webpack --progress --hide-modules" }, "xo": { "rules": {