web-service/webpack.config.js

35 lines
922 B
JavaScript
Raw Normal View History

2023-06-29 17:41:36 +00:00
/* 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,
}),
{},
);
};
module.exports = function (config) {
const appName = process.argv[process.argv.length - 1];
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;
};