webpack.common.js 918 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. const webpack = require("webpack");
  2. const HtmlWebpackPlugin = require("html-webpack-plugin");
  3. module.exports = {
  4. entry: "./src/index.js",
  5. output: {
  6. filename: "bundle.[hash].js",
  7. publicPath: "/",
  8. },
  9. target: "web",
  10. resolve: {
  11. alias: {
  12. "react-dom": "@hot-loader/react-dom",
  13. },
  14. },
  15. module: {
  16. rules: [
  17. {
  18. test: /\.(js)$/,
  19. exclude: /node_modules/,
  20. use: ["babel-loader"],
  21. },
  22. {
  23. test: /\.css$/i,
  24. use: ["style-loader", "css-loader"],
  25. },
  26. {
  27. test: /\.s[ac]ss$/i,
  28. use: ["style-loader", "css-loader", "sass-loader"],
  29. },
  30. {
  31. test: /\.(png|svg|jpg|jpeg|gif)$/i,
  32. type: "asset/resource",
  33. },
  34. ],
  35. },
  36. plugins: [
  37. new webpack.HotModuleReplacementPlugin(),
  38. new HtmlWebpackPlugin({
  39. template: "public/index.html",
  40. favicon: "public/favicon.ico",
  41. }),
  42. ],
  43. };