1
0

webpack.config.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright 2023 Avaiga Private Limited
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  5. * the License. You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  10. * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
  11. * specific language governing permissions and limitations under the License.
  12. */
  13. const webpack = require("webpack");
  14. const path = require("path");
  15. require("dotenv").config();
  16. module.exports = (_env, options) => {
  17. return {
  18. mode: options.mode, // "development" | "production"
  19. entry: ["./src/index.ts"],
  20. output: {
  21. filename: "exampleLibrary.js",
  22. path: path.resolve(__dirname, "dist"),
  23. library: {
  24. // Camel case transformation of the library name "example"
  25. name: "Example",
  26. type: "umd"
  27. },
  28. publicPath: "/",
  29. },
  30. // The Taipy GUI library is indicated as external so that it is
  31. // excluded from bundling.
  32. externals: {"taipy-gui": "TaipyGui"},
  33. // Enable sourcemaps for debugging webpack's output.
  34. devtool: options.mode === "development" && "inline-source-map",
  35. resolve: {
  36. // All the code is TypeScript
  37. extensions: [".ts", ".tsx"],
  38. },
  39. module: {
  40. rules: [
  41. {
  42. test: /\.tsx?$/,
  43. use: "ts-loader",
  44. exclude: /node_modules/,
  45. },
  46. ],
  47. },
  48. plugins: [
  49. new webpack.DllReferencePlugin({
  50. // We assume the current directory is orignal directory in the taipy-gui repository.
  51. // If this file is moved, this path must be updated
  52. manifest: path.resolve(
  53. __dirname,
  54. `${process.env.TAIPY_GUI_DIR}/taipy/gui/webapp/taipy-gui-deps-manifest.json`
  55. ),
  56. name: "TaipyGuiDependencies"
  57. }),
  58. ]
  59. };
  60. };