-
Notifications
You must be signed in to change notification settings - Fork 25
/
version.js
27 lines (24 loc) · 953 Bytes
/
version.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* ~/www/project-x/version.js */
var fs = require('fs')
var Version = require("node-version-assets");
var mapReplacer = new Version({
assets: ['src/frontend/public/assets/js/app.js.map'],
grepFiles: ['src/frontend/public/assets/js/app.js']
})
mapReplacer.run(function() {
// For some reason the map replacer doesn't work
var newAppJsMapFile = null;
var assets = fs.readdirSync('src/frontend/public/assets/js')
assets.forEach(function(assetName) {
if (assetName.match(/^app\.js\..*\.map$/))
newAppJsMapFile = assetName
})
var appJsContents = fs.readFileSync('src/frontend/public/assets/js/app.js', 'utf8')
var results = appJsContents.replace('app.js.map', newAppJsMapFile)
fs.writeFileSync('src/frontend/public/assets/js/app.js', results, 'utf8')
var assetReplacer = new Version({
assets: ['src/frontend/public/assets/js/app.js'],
grepFiles: ['src/frontend/public/index.html']
});
assetReplacer.run()
})