webpack.config.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. const path = require("path");
  2. const webpack = require("webpack");
  3. const CopyWebpackPlugin = require("copy-webpack-plugin");
  4. const resolveApp = (relativePath) => path.resolve(__dirname, relativePath);
  5. const moduleName = "TaipyGuiBase";
  6. const basePath = "../../../taipy/gui/webapp";
  7. const webAppPath = resolveApp(basePath);
  8. const taipyGuiBaseExportPath = resolveApp(basePath + "/taipy-gui-base-export");
  9. module.exports = [
  10. {
  11. target: "web",
  12. entry: {
  13. default: "./base/src/index.ts",
  14. },
  15. output: {
  16. filename: (arg) => {
  17. if (arg.chunk.name === "default") {
  18. return "taipy-gui-base.js";
  19. }
  20. return "[name].taipy-gui-base.js";
  21. },
  22. chunkFilename: "[name].taipy-gui-base.js",
  23. path: webAppPath,
  24. globalObject: "this",
  25. library: {
  26. name: moduleName,
  27. type: "umd",
  28. },
  29. },
  30. optimization: {
  31. splitChunks: {
  32. chunks: "all",
  33. name: "shared",
  34. },
  35. },
  36. module: {
  37. rules: [
  38. {
  39. test: /\.tsx?$/,
  40. use: "ts-loader",
  41. exclude: /node_modules/,
  42. },
  43. ],
  44. },
  45. resolve: {
  46. extensions: [".tsx", ".ts", ".js", ".tsx"],
  47. },
  48. // externals: {
  49. // "socket.io-client": {
  50. // commonjs: "socket.io-client",
  51. // commonjs2: "socket.io-client",
  52. // amd: "socket.io-client",
  53. // root: "_",
  54. // },
  55. // },
  56. },
  57. {
  58. entry: "./base/src/exports.ts",
  59. output: {
  60. filename: "taipy-gui-base.js",
  61. path: taipyGuiBaseExportPath,
  62. library: {
  63. name: moduleName,
  64. type: "umd",
  65. },
  66. publicPath: "",
  67. },
  68. module: {
  69. rules: [
  70. {
  71. test: /\.tsx?$/,
  72. use: "ts-loader",
  73. exclude: /node_modules/,
  74. },
  75. ],
  76. },
  77. resolve: {
  78. extensions: [".tsx", ".ts", ".js", ".tsx"],
  79. },
  80. plugins: [
  81. new CopyWebpackPlugin({
  82. patterns: [{ from: "./base/src/packaging", to: taipyGuiBaseExportPath }],
  83. }),
  84. ],
  85. },
  86. ];