webpack.rules.ts 832 B

123456789101112131415161718192021222324252627282930313233343536
  1. import type { ModuleOptions } from 'webpack'
  2. export const rules: Required<ModuleOptions>['rules'] = [
  3. // Add support for native node modules
  4. {
  5. // We're specifying native_modules in the test because the asset relocator loader generates a
  6. // "fake" .node file which is really a cjs file.
  7. test: /native_modules[/\\].+\.node$/,
  8. use: 'node-loader',
  9. },
  10. {
  11. test: /[/\\]node_modules[/\\].+\.(m?js|node)$/,
  12. parser: { amd: false },
  13. use: {
  14. loader: '@vercel/webpack-asset-relocator-loader',
  15. options: {
  16. outputAssetBase: 'native_modules',
  17. },
  18. },
  19. },
  20. {
  21. test: /\.tsx?$/,
  22. exclude: /(node_modules|\.webpack)/,
  23. use: {
  24. loader: 'ts-loader',
  25. options: {
  26. transpileOnly: true,
  27. },
  28. },
  29. },
  30. {
  31. test: /\.svg$/,
  32. use: ['@svgr/webpack'],
  33. },
  34. ]