-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgetSettings.js
44 lines (41 loc) · 1.22 KB
/
getSettings.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
33
34
35
36
37
38
39
40
41
42
43
44
const path = require('path');
const fs = require('fs');
function resolvePath(file) {
if (fs.existsSync(path.resolve(__dirname, '../../../' + file))) {
return './' + file;
}
return './node_modules/@pluswerk/webpack-config/' + file;
}
const defaultSettings = {
directory: {
typescript: 'Typescript/',
scss: 'Scss/',
generated: 'Generated/',
publicPath: null,
},
files: {
tsConfig: resolvePath('tsconfig.json'),
tsLint: resolvePath('tslint.json'),
stylelint: resolvePath('stylelint.config.js'),
},
entry: {},
envPath: '.env',
serverActiveEnv: 'NODE_ACTIVE=TRUE',
serverInactiveEnv: 'NODE_ACTIVE=FALSE',
webpackConfig: {},
};
module.exports = function () {
let settings = defaultSettings;
const buildSettingsFile = path.resolve(__dirname, '../../../build.settings.js');
let buildSettings = {};
try {
buildSettings = require(buildSettingsFile);
} catch (e) {
throw new Error('You need to have a build.settings.js file at location: ' + buildSettingsFile + '.' + '\n' + (e.message || ''));
}
Object.assign(settings, buildSettings);
if (settings.directory.publicPath === null) {
settings.directory.publicPath = settings.directory.generated;
}
return settings;
};