63 lines
1.4 KiB
JavaScript
63 lines
1.4 KiB
JavaScript
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
const glob = require('glob');
|
|
const path = require('path');
|
|
|
|
const writeGlobEntry = (pattern, to) => {
|
|
return glob.sync(pattern).reduce(
|
|
(collection, file) => ({
|
|
...collection,
|
|
[`${to}/${path.basename(file, '.ts')}`]: file,
|
|
}),
|
|
{},
|
|
);
|
|
};
|
|
|
|
const appName = process.argv[process.argv.length - 1];
|
|
|
|
const configs = [
|
|
function (config) {
|
|
config.entry = {
|
|
main: path.join(__dirname, 'apps', appName, 'src', 'main.ts'),
|
|
...writeGlobEntry(
|
|
path.resolve('apps', appName, 'src', 'database', 'migrations', '*.ts'),
|
|
'database/migrations',
|
|
),
|
|
...writeGlobEntry(
|
|
path.resolve('apps', appName, 'src', 'database', 'seeds', '*.ts'),
|
|
'database/seeds',
|
|
),
|
|
};
|
|
config.output = {
|
|
path: `${__dirname}/dist/apps/${appName}`,
|
|
filename: '[name].js',
|
|
libraryTarget: 'commonjs',
|
|
};
|
|
|
|
return config;
|
|
},
|
|
];
|
|
|
|
if (appName === 'render') {
|
|
const config2 = {
|
|
entry: {
|
|
renderer:
|
|
appName === 'render'
|
|
? path.resolve('apps', appName, 'src', 'renderer', 'index.ts')
|
|
: undefined,
|
|
},
|
|
target: 'web',
|
|
externalsPresets: {},
|
|
externals: {
|
|
'@dimforge/rapier3d': 'RAPIER',
|
|
},
|
|
output: {
|
|
path: `${__dirname}/dist/apps/${appName}`,
|
|
filename: '[name].js',
|
|
libraryTarget: '',
|
|
},
|
|
};
|
|
configs.push(config2);
|
|
}
|
|
|
|
module.exports = configs;
|