webpack.config.js 1.0 KB

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