const path = require('path'); const TerserPlugin = require('terser-webpack-plugin'); const frontendConf = { mode: 'production', target: "web", output: { path: path.resolve(__dirname, 'lib'), libraryTarget: 'commonjs', }, module: { rules: [ { test: /\.ts?$/, loader: "ts-loader" } ] }, resolve: { extensions: [".ts", ".tsx", ".js"] }, optimization: { minimize: true, minimizer: [ new TerserPlugin({ parallel: true, exclude: [ /\.\/(.*)\/.ts/, /\.\/(.*).ts/, ], }), ], }, } const backendConf = { mode: 'production', target: "node", output: { path: path.resolve(__dirname, 'lib'), libraryTarget: 'commonjs', }, module: { rules: [ { test: /\.ts?$/, loader: "ts-loader" } ] }, resolve: { extensions: [".ts", ".tsx", ".js"] }, optimization: { minimize: true, minimizer: [ new TerserPlugin({ parallel: true, exclude: [ /\.\/(.*)\/.ts/, /\.\/(.*).ts/, ], }), ], }, } const clientConf = { ...frontendConf, ...{ entry: path.resolve(__dirname, 'src', 'Client.ts'), output: { filename: 'Frontend.js', } } } const clientTestConf = { ...frontendConf, ...{ entry: path.resolve(__dirname, 'test', 'TestClient.ts'), output: { filename: 'TestFrontend.js', } } } const serverConf = { ...backendConf, ...{ entry: path.resolve(__dirname, 'src', 'Server.ts'), output: { filename: 'Backend.js', } } } const serverTestConf = { ...backendConf, ...{ entry: path.resolve(__dirname, 'test', 'TestServer.ts'), output: { filename: 'TestBackend.js', } } } module.exports = [clientConf, clientTestConf, serverConf, serverTestConf]