You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

webpack.js 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. const path = require('path');
  2. const TerserPlugin = require('terser-webpack-plugin');
  3. const frontendConf = {
  4. mode: 'production',
  5. target: "web",
  6. output: {
  7. path: path.resolve(__dirname, 'lib'),
  8. libraryTarget: 'commonjs',
  9. },
  10. module: {
  11. rules: [
  12. { test: /\.ts?$/, loader: "ts-loader" }
  13. ]
  14. },
  15. resolve: {
  16. extensions: [".ts", ".tsx", ".js"]
  17. },
  18. optimization: {
  19. minimize: true,
  20. minimizer: [
  21. new TerserPlugin({
  22. parallel: true,
  23. exclude: [
  24. /\.\/(.*)\/.ts/,
  25. /\.\/(.*).ts/,
  26. ],
  27. }),
  28. ],
  29. },
  30. }
  31. const backendConf = {
  32. mode: 'production',
  33. target: "node",
  34. output: {
  35. path: path.resolve(__dirname, 'lib'),
  36. libraryTarget: 'commonjs',
  37. },
  38. module: {
  39. rules: [
  40. { test: /\.ts?$/, loader: "ts-loader" }
  41. ]
  42. },
  43. resolve: {
  44. extensions: [".ts", ".tsx", ".js"]
  45. },
  46. optimization: {
  47. minimize: true,
  48. minimizer: [
  49. new TerserPlugin({
  50. parallel: true,
  51. exclude: [
  52. /\.\/(.*)\/.ts/,
  53. /\.\/(.*).ts/,
  54. ],
  55. }),
  56. ],
  57. },
  58. }
  59. const clientConf = {
  60. ...frontendConf,
  61. ...{
  62. entry: path.resolve(__dirname, 'src', 'Client.ts'),
  63. output: {
  64. filename: 'Frontend.js',
  65. }
  66. }
  67. }
  68. const clientTestConf = {
  69. ...frontendConf,
  70. ...{
  71. entry: path.resolve(__dirname, 'test', 'TestClient.ts'),
  72. output: {
  73. filename: 'TestFrontend.js',
  74. }
  75. }
  76. }
  77. const serverConf = {
  78. ...backendConf,
  79. ...{
  80. entry: path.resolve(__dirname, 'src', 'Server.ts'),
  81. output: {
  82. filename: 'Backend.js',
  83. }
  84. }
  85. }
  86. const serverTestConf = {
  87. ...backendConf,
  88. ...{
  89. entry: path.resolve(__dirname, 'test', 'TestServer.ts'),
  90. output: {
  91. filename: 'TestBackend.js',
  92. }
  93. }
  94. }
  95. module.exports = [clientConf, clientTestConf, serverConf, serverTestConf]