You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

webpack.config.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. const path = require('path');
  2. const webpack = require('webpack');
  3. const HtmlWebpackPlugin = require('html-webpack-plugin');
  4. module.exports = {
  5. entry: path.join(__dirname, "src", "index.js"),
  6. output: {
  7. filename: 'main.js',
  8. path: path.resolve(__dirname, 'dist'),
  9. clean: true,
  10. },
  11. resolve: {
  12. alias: {
  13. 'client': path.join(__dirname, '../pkg/'),
  14. 'react-dom': path.resolve('./node_modules/react-dom'),
  15. react: path.resolve('./node_modules/react')
  16. },
  17. fallback: {
  18. "buffer": require.resolve("buffer"),
  19. },
  20. extensions: ['*', '.js', '.jsx'],
  21. },
  22. mode: "development",
  23. devServer: {
  24. static: {
  25. directory: path.join(__dirname, 'dist'),
  26. },
  27. compress: true,
  28. port: 9000,
  29. client: {
  30. logging: 'none',
  31. progress: true,
  32. overlay: {
  33. errors: true,
  34. warnings: false,
  35. }
  36. },
  37. },
  38. module: {
  39. rules: [
  40. {
  41. test: /\.(js|jsx)$/,
  42. exclude: /node_modules/,
  43. use: ["babel-loader"],
  44. },
  45. {
  46. test: /\.css?$/,
  47. use: 'css-loader',
  48. },
  49. ],
  50. },
  51. plugins: [
  52. new webpack.ProvidePlugin({
  53. Buffer: ['buffer', 'Buffer'],
  54. }),
  55. new HtmlWebpackPlugin({
  56. template: path.join(__dirname, "public", "index.html"),
  57. }),
  58. ],
  59. experiments: {
  60. asyncWebAssembly: true,
  61. topLevelAwait: true
  62. }
  63. };