diff --git a/src/webpack.js b/src/webpack.js new file mode 100644 index 0000000..1178ac5 --- /dev/null +++ b/src/webpack.js @@ -0,0 +1,67 @@ +const path = require('path'); +const TerserPlugin = require('terser-webpack-plugin'); + + +const frontendConf = { + mode: 'production', + target: "web", + entry: path.resolve(__dirname, 'src', 'Frontend.ts'), + output: { + path: path.resolve(__dirname, 'lib'), + filename: "Frontend.js", + 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", +entry: path.resolve(__dirname, 'src', 'Backend.ts'), +output: { + path: path.resolve(__dirname, 'lib'), + filename: "Backend.js", + 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/, + ], + }), + ], +}, +} + +module.exports = [frontendConf, backendConf] diff --git a/test/webpack.js b/test/webpack.js new file mode 100644 index 0000000..a686054 --- /dev/null +++ b/test/webpack.js @@ -0,0 +1,101 @@ +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]