webpack.config.js 2.5 KB

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