2021-01-20 16:31:34 +01:00
|
|
|
/*
|
2021-03-17 19:05:39 +01:00
|
|
|
* Load webpack configuration from webpack.yml
|
2021-01-20 16:31:34 +01:00
|
|
|
*/
|
|
|
|
|
2021-03-17 19:05:39 +01:00
|
|
|
const YML_PATH = './webpack.yml';
|
2021-03-14 21:46:04 +01:00
|
|
|
const CONF_VAR = 'App\\Templates\\WebpackTemplateProvider';
|
2021-02-21 09:17:41 +01:00
|
|
|
|
2021-01-20 16:31:34 +01:00
|
|
|
const path = require('path');
|
|
|
|
const filesystem = require('fs');
|
|
|
|
const fs = require('fs');
|
|
|
|
const yaml = require('js-yaml');
|
|
|
|
|
|
|
|
const conf = yaml.safeLoad(
|
2021-03-14 21:46:04 +01:00
|
|
|
fs.readFileSync(path.join(__dirname, YML_PATH), 'utf8'),
|
2021-01-20 16:31:34 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
let themes = [];
|
|
|
|
// add themes
|
2021-03-14 21:46:04 +01:00
|
|
|
if (conf[CONF_VAR].THEMESDIR) {
|
|
|
|
const themeDir = conf[CONF_VAR].THEMESDIR;
|
|
|
|
const dir = path.resolve(__dirname, themeDir);
|
2021-01-20 16:31:34 +01:00
|
|
|
|
2021-03-14 21:46:04 +01:00
|
|
|
if (filesystem.existsSync(dir)) {
|
|
|
|
filesystem.readdirSync(dir).forEach((file) => {
|
|
|
|
filePath = path.join(themeDir, file);
|
|
|
|
const stat = filesystem.statSync(filePath);
|
2021-01-20 16:31:34 +01:00
|
|
|
|
2021-03-14 21:46:04 +01:00
|
|
|
if (stat && stat.isDirectory()) {
|
|
|
|
themes.push(filePath);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2021-01-20 16:31:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
2021-03-14 21:46:04 +01:00
|
|
|
configuration: conf[CONF_VAR],
|
|
|
|
themes: themes,
|
2021-01-20 16:31:34 +01:00
|
|
|
};
|