From 3c5044f137a26ecb33f6c02fb936dd61cd3f37f0 Mon Sep 17 00:00:00 2001 From: Xaver Maierhofer Date: Wed, 1 Feb 2017 22:41:29 +0100 Subject: [PATCH] [TASK] Add cache breaker as variable and scss --- .sass-lint.yml | 2 ++ README.md | 6 ++++++ assets/icons/icon.scss | 8 +++++--- config.json | 3 ++- lib/main.js | 2 +- tasks/build.js | 11 ++++++++++- 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.sass-lint.yml b/.sass-lint.yml index e8ac9c6..a7e4640 100644 --- a/.sass-lint.yml +++ b/.sass-lint.yml @@ -5,3 +5,5 @@ rules: no-vendor-prefixes: 0 # Needed for old 'display: -vendor-prefix-property' for higher browser-support no-duplicate-properties: 0 + # Needed for unique-id() + empty-args: 0 diff --git a/README.md b/README.md index fb9b3dd..6e0660c 100644 --- a/README.md +++ b/README.md @@ -261,6 +261,12 @@ Example for `supportedLocale`: "en", "de" ] + +## cacheBreaker (string) + +Will be replaced in every build to avoid missing or outdated language strings, because language.json isn't up to date. + +_Fixed value (y0z)._ ## Sponsoring / Supporting - [BrowserStack](https://www.browserstack.com/) for providing a awesome testing service for hundreds of browsers diff --git a/assets/icons/icon.scss b/assets/icons/icon.scss index 89ca76a..af30a52 100644 --- a/assets/icons/icon.scss +++ b/assets/icons/icon.scss @@ -1,13 +1,15 @@ // Needed for standalone scss // @import 'icon-mixin'; +$cache-breaker: unique-id(); + @font-face { font-family: 'ionicons'; font-style: normal; font-weight: normal; - src: url('fonts/icon.woff2') format('woff2'), - url('fonts/icon.woff') format('woff'), - url('fonts/icon.ttf') format('truetype'); + src: url('fonts/icon.woff2?rel=#{$cache-breaker}') format('woff2'), + url('fonts/icon.woff?rel=#{$cache-breaker}') format('woff'), + url('fonts/icon.ttf?rel=#{$cache-breaker}') format('truetype'); } [class^='ion-'], [class*=' ion-'] { diff --git a/config.json b/config.json index a26bd21..113093d 100644 --- a/config.json +++ b/config.json @@ -114,5 +114,6 @@ "supportedLocale": [ "en", "de" - ] + ], + "cacheBreaker": "y0z" } diff --git a/lib/main.js b/lib/main.js index 9dcc039..d42e2b4 100644 --- a/lib/main.js +++ b/lib/main.js @@ -178,7 +178,7 @@ define(['polyglot', 'moment', 'router', 'leaflet', 'gui', 'helper'], }); window._ = new Polyglot({locale: locale, allowMissing: true}); - helper.getJSON('locale/' + _.locale() + '.json').then(setTranslation); + helper.getJSON('locale/' + _.locale() + '.json?' + config.cacheBreaker).then(setTranslation); var router = new Router(); diff --git a/tasks/build.js b/tasks/build.js index 08ce777..7c2b2fe 100644 --- a/tasks/build.js +++ b/tasks/build.js @@ -149,13 +149,22 @@ module.exports = function exports(grunt) { } }, cachebreaker: { - default: { + js: { options: { match: ['app.js'] }, files: { src: ['build/index.html'] } + }, + variable: { + options: { + match: ['y*z'], + position: 'overwrite' + }, + files: { + src: ['build/config.json'] + } } } });