-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
28 lines (22 loc) · 854 Bytes
/
index.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
28
const fs = require('fs');
function AssetsVersioning (options) {
this.options = options || {}
}
AssetsVersioning.prototype.apply = function apply (compiler) {
const options = this.options;
const class_name = this.options.class_name || "AssetsVersion"
const file_name = this.options.file_name || "./assets.version.php"
compiler.hooks.done.tap('Assets Version', () => {
const stamp = Date.now();
const content = '<?php\n' +
'\n' +
'class '+ class_name +' {\n' +
'\tpublic $current = '+ stamp +';\n' +
'}';
fs.writeFile(file_name, content, (err) => {
if (err) throw err;
console.log('Assets version updated');
});
});
};
module.exports = AssetsVersioning;