webpack.config.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. const path = require("path");
  2. const webpack = require("webpack");
  3. const HtmlWebpackPlugin = require("html-webpack-plugin");
  4. const { CleanWebpackPlugin } = require("clean-webpack-plugin");
  5. const CopyPlugin = require("copy-webpack-plugin");
  6. module.exports = {
  7. entry: {
  8. main: "./src/index.js"
  9. },
  10. module: {
  11. rules: [
  12. {
  13. test: /\.m?js$/,
  14. exclude: /node_modules/,
  15. use: {
  16. loader: "babel-loader",
  17. options: {
  18. presets: ["@babel/preset-env"],
  19. plugins: ["@babel/plugin-proposal-class-properties"]
  20. }
  21. }
  22. }
  23. ]
  24. },
  25. output: {
  26. path: path.resolve(__dirname, "./dist"),
  27. filename: "[name]-[contenthash].bundle.js",
  28. },
  29. devServer: {
  30. historyApiFallback: true,
  31. contentBase: path.resolve(__dirname, "./dist"),
  32. open: true,
  33. hot: true,
  34. port: 8080,
  35. },
  36. plugins: [
  37. new HtmlWebpackPlugin({
  38. template: path.join(__dirname, "src/index.html"),
  39. minify: false
  40. }),
  41. new CleanWebpackPlugin(),
  42. new CopyPlugin({
  43. patterns: [
  44. {
  45. from: "static",
  46. globOptions: {
  47. ignore: ["**/publicroot"]
  48. }
  49. }
  50. ]
  51. }),
  52. new webpack.HotModuleReplacementPlugin(),
  53. ]
  54. };