webpack.prod.config.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. const webpack = require("webpack");
  2. const path = require("path");
  3. const BundleAnalyzerPlugin = require("webpack-bundle-analyzer")
  4. .BundleAnalyzerPlugin;
  5. module.exports = {
  6. mode: "production",
  7. entry: { "excalidraw-utils.min": "./index.js" },
  8. output: {
  9. path: path.resolve(__dirname, "dist"),
  10. filename: "[name].js",
  11. library: "ExcalidrawUtils",
  12. libraryTarget: "umd",
  13. },
  14. resolve: {
  15. extensions: [".tsx", ".ts", ".js", ".css", ".scss"],
  16. },
  17. optimization: {
  18. runtimeChunk: false,
  19. },
  20. module: {
  21. rules: [
  22. {
  23. test: /\.(sa|sc|c)ss$/,
  24. exclude: /node_modules/,
  25. use: ["style-loader", { loader: "css-loader" }, "sass-loader"],
  26. },
  27. {
  28. test: /\.(ts|tsx|js)$/,
  29. use: [
  30. {
  31. loader: "ts-loader",
  32. options: {
  33. transpileOnly: true,
  34. configFile: path.resolve(__dirname, "../tsconfig.prod.json"),
  35. },
  36. },
  37. ],
  38. },
  39. ],
  40. },
  41. plugins: [
  42. new webpack.optimize.LimitChunkCountPlugin({
  43. maxChunks: 1,
  44. }),
  45. ...(process.env.ANALYZER === "true" ? [new BundleAnalyzerPlugin()] : []),
  46. ],
  47. };