webpack.config.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. const path = require('path');
  2. const HtmlWebpackPlugin = require('html-webpack-plugin');
  3. const MiniCssExtractPlugin = require("mini-css-extract-plugin");
  4. const CopyPlugin = require("copy-webpack-plugin");
  5. module.exports = {
  6. entry: ['./src/index.js'],
  7. mode: "production",
  8. target: "web",
  9. module: {
  10. rules: [
  11. {
  12. test: /\.(js|jsx)$/i,
  13. exclude: /(node_modules|bower_components)/,
  14. use: {
  15. loader: 'babel-loader',
  16. options: {
  17. presets: ['@babel/preset-env', "@babel/preset-react"],
  18. }
  19. }
  20. },
  21. {
  22. test: /\.s[ac]ss$/i,
  23. use: [MiniCssExtractPlugin.loader, "css-loader", "sass-loader"],
  24. },
  25. {
  26. test: /\.css$/i,
  27. use: [MiniCssExtractPlugin.loader, "css-loader"],
  28. }
  29. ],
  30. },
  31. plugins: [new HtmlWebpackPlugin({
  32. template: path.resolve("src", "index.html")
  33. }), new MiniCssExtractPlugin(),
  34. new CopyPlugin({
  35. patterns: [
  36. { from: "src/assets", to: "assets" }
  37. ],
  38. })],
  39. output: {
  40. path: path.resolve(__dirname, 'build'),
  41. filename: '[name].d3v4pp.bundle.js',
  42. publicPath: "/"
  43. },
  44. devServer: {
  45. client: {
  46. progress: true,
  47. reconnect: true,
  48. overlay: {
  49. errors: true,
  50. warnings: false,
  51. },
  52. },
  53. hot: true,
  54. historyApiFallback: true,
  55. open: true,
  56. static: {
  57. directory: path.join(__dirname, 'src'),
  58. },
  59. compress: true,
  60. port: 9000,
  61. }
  62. };