1
0

webpack.config.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright 2021-2024 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. const ESLintPlugin = require("eslint-webpack-plugin");
  16. require("dotenv").config();
  17. module.exports = (_env, options) => {
  18. return {
  19. mode: options.mode, // "development" | "production"
  20. entry: ["./src/index.ts"],
  21. output: {
  22. filename: "taipy-gui-core.js",
  23. path: path.resolve(__dirname, "../../taipy/gui_core/lib"),
  24. library: {
  25. // Camel case transformation of the library name "example"
  26. name: "TaipyGuiCore",
  27. type: "umd",
  28. },
  29. publicPath: "/",
  30. },
  31. // The Taipy GUI library is indicated as external so that it is
  32. // excluded from bundling.
  33. externals: { "taipy-gui": "TaipyGui" },
  34. // Enable sourcemaps for debugging webpack's output.
  35. devtool: options.mode === "development" && "inline-source-map",
  36. resolve: {
  37. // All the code is TypeScript
  38. extensions: [".ts", ".tsx", ".js"],
  39. },
  40. module: {
  41. rules: [
  42. {
  43. test: /\.tsx?$/,
  44. use: "ts-loader",
  45. exclude: /node_modules/,
  46. },
  47. ],
  48. },
  49. plugins: [
  50. new webpack.DllReferencePlugin({
  51. // We assume the current directory is original directory in the taipy-gui repository.
  52. // If this file is moved, this path must be updated
  53. manifest: path.resolve(
  54. __dirname,
  55. `${process.env.TAIPY_DIR}/taipy/gui/webapp/taipy-gui-deps-manifest.json`
  56. ),
  57. name: "TaipyGuiDependencies",
  58. }),
  59. new ESLintPlugin({
  60. extensions: [`ts`, `tsx`],
  61. exclude: [`/node_modules/`],
  62. eslintPath: require.resolve("eslint"),
  63. }),
  64. ],
  65. };
  66. };