webpack.prod.config.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. const webpack = require("webpack");
  2. const path = require("path");
  3. const BundleAnalyzerPlugin =
  4. require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
  5. module.exports = {
  6. mode: "production",
  7. entry: { "excalidraw-math.min": "./index.js" },
  8. output: {
  9. path: path.resolve(__dirname, "dist"),
  10. filename: "[name].js",
  11. library: "ExcalidrawMath",
  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: /\.(ts|tsx|js)$/,
  24. use: [
  25. {
  26. loader: "ts-loader",
  27. options: {
  28. transpileOnly: true,
  29. configFile: path.resolve(__dirname, "../tsconfig.prod.json"),
  30. },
  31. },
  32. {
  33. loader: "babel-loader",
  34. options: {
  35. presets: [
  36. "@babel/preset-env",
  37. ["@babel/preset-react", { runtime: "automatic" }],
  38. "@babel/preset-typescript",
  39. ],
  40. plugins: [["@babel/plugin-transform-runtime"]],
  41. },
  42. },
  43. ],
  44. },
  45. ],
  46. },
  47. plugins: [
  48. new webpack.optimize.LimitChunkCountPlugin({
  49. maxChunks: 1,
  50. }),
  51. ...(process.env.ANALYZER === "true" ? [new BundleAnalyzerPlugin()] : []),
  52. ],
  53. };