Skip to content

Commit 2bc983b

Browse files
feat(build): optionally include version in released filename
Instead of releasing the files: ``` semantic.css semantic.js semantic.min.css semantic.min.js ``` optionally release the files that include the version number and an optional revision string: ``` semantic-2.9.3-a.css semantic-2.9.3-a.js semantic-2.9.3-a.min.css semantic-2.9.3-a.min.js ``` The advantage is to make clear which version is currently being used, and preventing the browser cache from running an obsolete version. This pull-request is fully backward compatible as the default behaviour does not change at all. The change is activated in semantic.json by adding the relevant fields: ``` { // ... "permission": false, "autoInstall": false, "rtl": false, "includeVersionInFileName": true, <== Here "revision": "a", <== Optionally this, too. "version": "2.9.3" <== version that is added. } ```
1 parent 84fc179 commit 2bc983b

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

tasks/config/project/release.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ const requireDotFile = require('require-dot-file');
77
let
88
config,
99
npmPackage,
10-
version
10+
version,
11+
revision,
12+
versionInFileName,
13+
includeVersionInFileName
1114
;
1215

1316
/*******************************
@@ -31,6 +34,20 @@ version = npmPackage && npmPackage.version !== undefined && npmPackage.name ===
3134
? npmPackage.version
3235
: config.version;
3336

37+
// looks for revision in config.
38+
revision = config.revision === undefined ? '' : config.revision;
39+
40+
includeVersionInFileName = config.includeVersionInFileName === undefined ? false : config.includeVersionInFileName;
41+
42+
versionInFileName = '';
43+
44+
if (includeVersionInFileName) {
45+
versionInFileName = '-' + version;
46+
if (revision !== '') {
47+
versionInFileName += '-' + revision;
48+
}
49+
}
50+
3451
/*******************************
3552
Export
3653
*******************************/
@@ -54,5 +71,6 @@ module.exports = {
5471
+ ' */\n',
5572

5673
version: version,
74+
versionInFileName: versionInFileName,
5775

5876
};

tasks/config/tasks.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ module.exports = {
4040
},
4141

4242
filenames: {
43-
concatenatedCSS: 'semantic.css',
44-
concatenatedJS: 'semantic.js',
45-
concatenatedMinifiedCSS: 'semantic.min.css',
46-
concatenatedMinifiedJS: 'semantic.min.js',
47-
concatenatedRTLCSS: 'semantic.rtl.css',
48-
concatenatedMinifiedRTLCSS: 'semantic.rtl.min.css',
43+
concatenatedCSS: 'semantic' + release.versionInFileName + '.css',
44+
concatenatedJS: 'semantic' + release.versionInFileName + '.js',
45+
concatenatedMinifiedCSS: 'semantic' + release.versionInFileName + '.min.css',
46+
concatenatedMinifiedJS: 'semantic' + release.versionInFileName + '.min.js',
47+
concatenatedRTLCSS: 'semantic' + release.versionInFileName + '.rtl.css',
48+
concatenatedMinifiedRTLCSS: 'semantic' + release.versionInFileName + '.rtl.min.css',
4949
},
5050

5151
regExp: {

0 commit comments

Comments
 (0)