webpack.config.cjs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. const path = require("path");
  2. const HtmlWebpackPlugin = require("html-webpack-plugin");
  3. const webpack = require("webpack");
  4. module.exports = {
  5. entry: "./index.ts",
  6. output: {
  7. path: path.resolve(__dirname, "./dist"),
  8. filename: "index.js",
  9. },
  10. module: {
  11. rules: [
  12. {
  13. test: /\.ts$/,
  14. use: "ts-loader",
  15. exclude: /node_modules/,
  16. },
  17. // TODO(appcypher): Wasm inlining does not work yet because of an issue with webpack/wasm-bindgen
  18. // See: https://rustwasm.github.io/wasm-bindgen/examples/hello-world.html
  19. // {
  20. // test: /\.wasm$/,
  21. // type: "asset/inline",
  22. // },
  23. ],
  24. },
  25. plugins: [
  26. new HtmlWebpackPlugin(),
  27. // Have this example work in Edge which doesn't ship `TextEncoder` or
  28. // `TextDecoder` at this time.
  29. new webpack.ProvidePlugin({
  30. TextDecoder: ["text-encoding", "TextDecoder"],
  31. TextEncoder: ["text-encoding", "TextEncoder"],
  32. }),
  33. ],
  34. resolve: {
  35. extensions: ['.ts', '.js'],
  36. },
  37. mode: "development",
  38. experiments: {
  39. asyncWebAssembly: true,
  40. topLevelAwait: true,
  41. },
  42. };