2018-02-22 14:39:58 +01:00
|
|
|
/*
|
|
|
|
* Common Environment
|
|
|
|
*/
|
|
|
|
|
2018-04-21 05:36:06 +02:00
|
|
|
const webpack = require('webpack');
|
2019-05-23 13:02:32 +02:00
|
|
|
const commonVariables = require('./webpack.configuration');
|
|
|
|
const conf = commonVariables.configuration;
|
2018-02-22 14:39:58 +01:00
|
|
|
|
2018-04-21 05:36:06 +02:00
|
|
|
const path = require('path');
|
2019-04-11 00:15:29 +02:00
|
|
|
const filesystem = require('fs');
|
2018-02-05 12:11:01 +01:00
|
|
|
|
2020-12-28 00:29:43 +01:00
|
|
|
const UIInfo = require('./node_modules/@a2nt/ss-bootstrap-ui-webpack-boilerplate/package.json');
|
|
|
|
const UINAME = JSON.stringify(UIInfo.name);
|
|
|
|
const UIVERSION = JSON.stringify(UIInfo.version);
|
|
|
|
console.info(`%cUI Kit ${UINAME} ${UIVERSION}`, 'color:yellow;font-size:14px');
|
|
|
|
|
2019-04-11 00:15:29 +02:00
|
|
|
const includes = {};
|
2019-05-23 13:02:32 +02:00
|
|
|
const modules = [
|
2020-02-12 21:31:59 +01:00
|
|
|
path.resolve(__dirname, conf.APPDIR, 'client', 'src'),
|
|
|
|
path.resolve(__dirname, conf.APPDIR, 'client', 'src', 'js'),
|
|
|
|
path.resolve(__dirname, conf.APPDIR, 'client', 'src', 'scss'),
|
|
|
|
path.resolve(__dirname, conf.APPDIR, 'client', 'src', 'img'),
|
|
|
|
path.resolve(__dirname, conf.APPDIR, 'client', 'src', 'thirdparty'),
|
|
|
|
path.resolve(__dirname, conf.APPDIR, 'client', 'node_modules'),
|
|
|
|
path.resolve(__dirname, 'node_modules'),
|
2020-07-20 12:25:57 +02:00
|
|
|
path.resolve(__dirname),
|
|
|
|
path.resolve(__dirname, 'public'),
|
2019-05-23 13:02:32 +02:00
|
|
|
];
|
2019-04-11 00:15:29 +02:00
|
|
|
|
2020-07-20 12:25:57 +02:00
|
|
|
const _addAppFiles = (theme) => {
|
2020-02-12 21:31:59 +01:00
|
|
|
const dirPath = path.resolve(__dirname, theme);
|
|
|
|
const themeName = path.basename(theme);
|
|
|
|
|
|
|
|
if (filesystem.existsSync(path.join(dirPath, conf.SRC, 'js', 'app.js'))) {
|
|
|
|
includes[`${themeName}`] = path.join(dirPath, conf.SRC, 'js', 'app.js');
|
|
|
|
} else if (
|
|
|
|
filesystem.existsSync(path.join(dirPath, conf.SRC, 'scss', 'app.scss'))
|
|
|
|
) {
|
|
|
|
includes[`${themeName}`] = path.join(
|
|
|
|
dirPath,
|
|
|
|
conf.SRC,
|
|
|
|
'scss',
|
|
|
|
'app.scss',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
modules.push(path.join(dirPath, 'client', 'src', 'js'));
|
|
|
|
modules.push(path.join(dirPath, 'client', 'src', 'scss'));
|
|
|
|
modules.push(path.join(dirPath, 'client', 'src', 'img'));
|
|
|
|
modules.push(path.join(dirPath, 'client', 'src', 'thirdparty'));
|
|
|
|
|
2020-07-20 12:25:57 +02:00
|
|
|
const _getAllFilesFromFolder = function (dir, includeSubFolders = true) {
|
2020-02-12 21:31:59 +01:00
|
|
|
const dirPath = path.resolve(__dirname, dir);
|
|
|
|
let results = [];
|
|
|
|
|
2020-07-20 12:25:57 +02:00
|
|
|
filesystem.readdirSync(dirPath).forEach((file) => {
|
2020-02-12 21:31:59 +01:00
|
|
|
if (file.charAt(0) === '_') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const filePath = path.join(dirPath, file);
|
|
|
|
const stat = filesystem.statSync(filePath);
|
|
|
|
|
|
|
|
if (stat && stat.isDirectory() && includeSubFolders) {
|
|
|
|
results = results.concat(
|
|
|
|
_getAllFilesFromFolder(filePath, includeSubFolders),
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
results.push(filePath);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return results;
|
|
|
|
};
|
|
|
|
|
|
|
|
// add page specific scripts
|
|
|
|
const typesJSPath = path.join(theme, conf.TYPESJS);
|
|
|
|
if (filesystem.existsSync(typesJSPath)) {
|
|
|
|
const pageScripts = _getAllFilesFromFolder(typesJSPath, true);
|
2020-07-20 12:25:57 +02:00
|
|
|
pageScripts.forEach((file) => {
|
2020-02-12 21:31:59 +01:00
|
|
|
includes[`${themeName}_${path.basename(file, '.js')}`] = file;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// add page specific scss
|
|
|
|
const typesSCSSPath = path.join(theme, conf.TYPESSCSS);
|
|
|
|
if (filesystem.existsSync(typesSCSSPath)) {
|
|
|
|
const scssIncludes = _getAllFilesFromFolder(typesSCSSPath, true);
|
2020-07-20 12:25:57 +02:00
|
|
|
scssIncludes.forEach((file) => {
|
2020-02-12 21:31:59 +01:00
|
|
|
includes[`${themeName}_${path.basename(file, '.scss')}`] = file;
|
|
|
|
});
|
|
|
|
}
|
2018-02-05 12:11:01 +01:00
|
|
|
};
|
|
|
|
|
2019-04-11 00:15:29 +02:00
|
|
|
_addAppFiles(conf.APPDIR);
|
2018-02-21 11:19:51 +01:00
|
|
|
|
2019-04-11 00:15:29 +02:00
|
|
|
// add themes
|
2020-07-20 12:25:57 +02:00
|
|
|
commonVariables.themes.forEach((theme) => {
|
2020-02-12 21:31:59 +01:00
|
|
|
_addAppFiles(theme);
|
2019-05-23 13:02:32 +02:00
|
|
|
});
|
2018-02-05 12:11:01 +01:00
|
|
|
|
|
|
|
module.exports = {
|
2020-02-12 21:31:59 +01:00
|
|
|
entry: includes,
|
|
|
|
externals: {
|
|
|
|
jquery: 'jQuery',
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
modules: modules,
|
|
|
|
alias: {
|
2020-12-28 00:29:43 +01:00
|
|
|
'window.jQuery': require.resolve('jquery'),
|
|
|
|
$: require.resolve('jquery'),
|
2020-02-12 21:31:59 +01:00
|
|
|
jquery: require.resolve('jquery'),
|
|
|
|
jQuery: require.resolve('jquery'),
|
|
|
|
},
|
|
|
|
},
|
2018-07-02 03:54:18 +02:00
|
|
|
};
|