webpack.config.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. const path = require("path");
  2. const webpack = require("webpack");
  3. const config = {
  4. entry: "./src/index.ts",
  5. output: {
  6. publicPath: path.resolve(__dirname, ""),
  7. path: path.resolve(__dirname, "dist"),
  8. filename: "main.js",
  9. },
  10. resolve: {
  11. extensions: [".ts", ".js", ".mjs", ".cjs", ".json"],
  12. fallback: { crypto: require.resolve("crypto-browserify"), stream: require.resolve("stream-browserify") },
  13. },
  14. plugins: [
  15. new webpack.ProvidePlugin({
  16. process: "process/browser.js",
  17. }),
  18. ],
  19. module: {
  20. rules: [
  21. {
  22. test: /\.ts$/,
  23. use: "babel-loader",
  24. exclude: /node_modules/,
  25. },
  26. {
  27. test: /\.mjs$/,
  28. include: /node_modules/,
  29. type: "javascript/auto",
  30. },
  31. {
  32. test: /\.cjs$/,
  33. include: path.resolve(__dirname, "node_modules/@polkadot/"),
  34. use: "babel-loader",
  35. },
  36. {
  37. test: /\.js$/,
  38. include: path.resolve(__dirname, "node_modules/@polkadot/"),
  39. use: "babel-loader",
  40. },
  41. ],
  42. },
  43. };
  44. module.exports = config;