webpack.config.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. const path = require("path");
  2. const MiniCssExtractPlugin = require("mini-css-extract-plugin");
  3. const RemoveEmptyScriptsPlugin = require("webpack-remove-empty-scripts");
  4. const CopyPlugin = require("copy-webpack-plugin");
  5. module.exports = {
  6. mode: process.env.NODE_ENV,
  7. entry: {
  8. index: path.resolve(__dirname, "resources/src/styles/index.scss"),
  9. },
  10. output: {
  11. path: path.resolve(__dirname, "resources/public"),
  12. },
  13. plugins: [
  14. new RemoveEmptyScriptsPlugin(),
  15. new MiniCssExtractPlugin({
  16. filename: "styles/[name].css",
  17. }),
  18. new CopyPlugin({
  19. patterns: [
  20. {
  21. from: path.resolve(__dirname, "resources/src/icons"),
  22. to: "icons",
  23. },
  24. {
  25. from: path.resolve(__dirname, "resources/src/index.html"),
  26. to: "index.html",
  27. },
  28. ],
  29. }),
  30. ],
  31. module: {
  32. rules: [
  33. {
  34. test: /\.scss$/i,
  35. exclude: /node_modules/,
  36. use: [
  37. MiniCssExtractPlugin.loader,
  38. {
  39. loader: "css-loader",
  40. options: {
  41. importLoaders: 1,
  42. },
  43. },
  44. "postcss-loader",
  45. "sass-loader",
  46. ],
  47. },
  48. {
  49. test: /\.(woff|woff2|eot|ttf|otf)$/i,
  50. type: "asset/resource",
  51. generator: {
  52. filename: "fonts/[hash][ext][query]",
  53. },
  54. },
  55. ],
  56. },
  57. };