Skip to content

Commit

Permalink
feat(build): optionally include version in released filename
Browse files Browse the repository at this point in the history
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.                                                                                                                                 
}
```
  • Loading branch information
dreaming-augustin authored Dec 22, 2024
1 parent 84fc179 commit 2bc983b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
20 changes: 19 additions & 1 deletion tasks/config/project/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ const requireDotFile = require('require-dot-file');
let
config,
npmPackage,
version
version,
revision,
versionInFileName,
includeVersionInFileName
;

/*******************************
Expand All @@ -31,6 +34,20 @@ version = npmPackage && npmPackage.version !== undefined && npmPackage.name ===
? npmPackage.version
: config.version;

// looks for revision in config.
revision = config.revision === undefined ? '' : config.revision;

includeVersionInFileName = config.includeVersionInFileName === undefined ? false : config.includeVersionInFileName;

versionInFileName = '';

if (includeVersionInFileName) {
versionInFileName = '-' + version;
if (revision !== '') {
versionInFileName += '-' + revision;
}
}

/*******************************
Export
*******************************/
Expand All @@ -54,5 +71,6 @@ module.exports = {
+ ' */\n',

version: version,
versionInFileName: versionInFileName,

};
12 changes: 6 additions & 6 deletions tasks/config/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ module.exports = {
},

filenames: {
concatenatedCSS: 'semantic.css',
concatenatedJS: 'semantic.js',
concatenatedMinifiedCSS: 'semantic.min.css',
concatenatedMinifiedJS: 'semantic.min.js',
concatenatedRTLCSS: 'semantic.rtl.css',
concatenatedMinifiedRTLCSS: 'semantic.rtl.min.css',
concatenatedCSS: 'semantic' + release.versionInFileName + '.css',
concatenatedJS: 'semantic' + release.versionInFileName + '.js',
concatenatedMinifiedCSS: 'semantic' + release.versionInFileName + '.min.css',
concatenatedMinifiedJS: 'semantic' + release.versionInFileName + '.min.js',
concatenatedRTLCSS: 'semantic' + release.versionInFileName + '.rtl.css',
concatenatedMinifiedRTLCSS: 'semantic' + release.versionInFileName + '.rtl.min.css',
},

regExp: {
Expand Down

0 comments on commit 2bc983b

Please sign in to comment.