-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathsettings_generator.js
32 lines (28 loc) · 1.01 KB
/
settings_generator.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
29
30
31
32
'use strict';
const SettingsGeneratorPlugin = (function () {
const EVENT_NAME = 'afterEnvironment';
const path = require('path');
const fs = require('fs');
function SettingsGeneratorPlugin(settingsData) {
this.settingsData = settingsData;
};
SettingsGeneratorPlugin.prototype.apply = function (compiler) {
if (compiler.hooks[EVENT_NAME]) {
compiler.hooks[EVENT_NAME].tap('settings-generator-plugin', () => {
fs.writeFile(
path.join(__dirname, "src", "settings.json"),
JSON.stringify(this.settingsData),
(error) => {
if (error) {
console.error(error);
} else {
console.log('settings.json generated correctly');
}
}
);
});
}
};
return SettingsGeneratorPlugin;
})();
module.exports = SettingsGeneratorPlugin;