webpack.config.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. const path = require("path");
  2. const webpack = require("webpack");
  3. const resolveApp = relativePath => path.resolve(__dirname, relativePath);
  4. const moduleName = "TaipyGuiBase";
  5. const basePath = "../../../taipy/gui/webapp";
  6. const webAppPath = resolveApp(basePath);
  7. module.exports = {
  8. target: "web",
  9. entry: {
  10. "default": "./base/src/index.ts",
  11. "preview": "./base/src/index-preview.ts",
  12. },
  13. output: {
  14. filename: (arg) => {
  15. if (arg.chunk.name === "default") {
  16. return "taipy-gui-base.js";
  17. }
  18. return "[name].taipy-gui-base.js";
  19. },
  20. chunkFilename: "[name].taipy-gui-base.js",
  21. path: webAppPath,
  22. globalObject: "this",
  23. library: {
  24. name: moduleName,
  25. type: "umd",
  26. },
  27. },
  28. optimization: {
  29. splitChunks: {
  30. chunks: 'all',
  31. },
  32. },
  33. module: {
  34. rules: [
  35. {
  36. test: /\.tsx?$/,
  37. use: "ts-loader",
  38. exclude: /node_modules/,
  39. },
  40. ],
  41. },
  42. resolve: {
  43. extensions: [".tsx", ".ts", ".js", ".tsx"],
  44. },
  45. // externals: {
  46. // "socket.io-client": {
  47. // commonjs: "socket.io-client",
  48. // commonjs2: "socket.io-client",
  49. // amd: "socket.io-client",
  50. // root: "_",
  51. // },
  52. // },
  53. };