[ALOY-999] Alloy: Add Compile time defines functionality
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | Low |
Status | Open |
Resolution | Unresolved |
Affected Version/s | Alloy 1.3.1 |
Fix Version/s | n/a |
Components | n/a |
Labels | n/a |
Reporter | Neville Dastur |
Assignee | Unknown |
Created | 2014-04-20T17:07:48.000+0000 |
Updated | 2018-03-07T22:25:52.000+0000 |
Description
In most build environments constants can be defined at build time. E.g. -D for make. This allows us to define a string such as the Git revision of the build or the build time. It would be great if alloy had this ability.
I tried doing it via manipulation of config.json in alloy.jmk, but pre-compile is invoked further into the compile process.
A hook where I could do this would be great:
task("pre:true-precompile",function(event,logger){
var now = new Date();
// Either this ....
event.alloyConfig.buildDate = now.toUTCString();
// ... or this
var fs = require('fs');
fs.readFile(event.dir.project + '/app/config.json', function(err, data) {
var config = JSON.parse( data );
config.global.buildDate = now.toUTCString();
var newConfig = JSON.stringify( config, null, 4);
fs.writeFile(event.dir.project + '/app/config.json', newConfig, function (err) {
if (err) throw err;
logger.info('New config.json saved.');
});
});
});
Moving this improvement request to engineering for further evaluation and prioritization.
Having passed 1st year anniversary I thought I would ask if it was for consideration? Thanks ;)