cache busting for js and css files

cpsdqs/unified-input
Ondřej Hruška 7 years ago
parent f6ab97a886
commit 9db61f0c1a
  1. 3
      _debug_replacements.php
  2. 2
      base.php
  3. 6
      build.sh
  4. 4
      pages/_head.php

@ -8,7 +8,6 @@
$vers = '???'; $vers = '???';
$versfn = __DIR__ . '/../user/version.h'; $versfn = __DIR__ . '/../user/version.h';
$myHash = shell_exec('git rev-parse --short HEAD');
$fwHash = '00000000'; $fwHash = '00000000';
if (file_exists($versfn)) { if (file_exists($versfn)) {
$f = file_get_contents($versfn); $f = file_get_contents($versfn);
@ -64,7 +63,7 @@ return [
'githubrepo' => 'https://github.com/espterm/espterm-firmware', 'githubrepo' => 'https://github.com/espterm/espterm-firmware',
'githubrepo_front' => 'https://github.com/espterm/espterm-front-end', 'githubrepo_front' => 'https://github.com/espterm/espterm-front-end',
'hash_backend' => $fwHash, 'hash_backend' => $fwHash,
'hash_frontend' => $myHash, // TODO actual versions? 'hash_frontend' => GIT_HASH, // TODO actual versions?
'ap_dhcp_time' => '120', 'ap_dhcp_time' => '120',
'ap_dhcp_start' => '192.168.4.100', 'ap_dhcp_start' => '192.168.4.100',

@ -16,6 +16,8 @@ if (!file_exists(__DIR__ . '/_env.php')) {
die("Copy <b>_env.php.example</b> to <b>_env.php</b> and check the settings inside!"); die("Copy <b>_env.php.example</b> to <b>_env.php</b> and check the settings inside!");
} }
define('GIT_HASH', trim(shell_exec('git rev-parse --short HEAD')));
require_once __DIR__ . '/_env.php'; require_once __DIR__ . '/_env.php';
$prod = defined('STDIN'); $prod = defined('STDIN');

@ -2,6 +2,8 @@
cd $(dirname $0) cd $(dirname $0)
FRONT_END_HASH=$(git rev-parse --short HEAD)
rm -r out/* rm -r out/*
mkdir out/js mkdir out/js
mkdir out/css mkdir out/css
@ -10,7 +12,7 @@ echo 'Generating lang.js...'
php ./dump_js_lang.php php ./dump_js_lang.php
echo 'Packing JS...' echo 'Packing JS...'
npm run babel -- -o out/js/app.js --source-maps js/lib \ npm run babel -- -o "out/js/app.$FRONT_END_HASH.js" --source-maps js/lib \
js/lib/chibi.js \ js/lib/chibi.js \
js/lib/keymaster.js \ js/lib/keymaster.js \
js/lib/polyfills.js \ js/lib/polyfills.js \
@ -27,7 +29,7 @@ npm run babel -- -o out/js/app.js --source-maps js/lib \
echo 'Building CSS...' echo 'Building CSS...'
npm run sass -- --output-style compressed sass/app.scss out/css/app.css npm run sass -- --output-style compressed sass/app.scss "out/css/app.$FRONT_END_HASH.css"
echo 'Building HTML...' echo 'Building HTML...'

@ -5,8 +5,8 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title><?= $_GET['PAGE_TITLE'] ?></title> <title><?= $_GET['PAGE_TITLE'] ?></title>
<link href="/css/app.css" rel="stylesheet"> <link href="/css/app.<?= GIT_HASH ?>.css" rel="stylesheet">
<script src="/js/app.js"></script> <script src="/js/app.<?= GIT_HASH ?>.js"></script>
<script> <script>
var _root = <?= JS_WEB_ROOT ?>; var _root = <?= JS_WEB_ROOT ?>;
var _demo = <?= (int)ESP_DEMO ?>; var _demo = <?= (int)ESP_DEMO ?>;

Loading…
Cancel
Save