webpack.renderer.config.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import type { Configuration } from "webpack";
  2. import path from "path";
  3. import { rules } from "./webpack.rules";
  4. import { plugins } from "./webpack.plugins";
  5. rules.push(
  6. {
  7. test: /\.css$/,
  8. use: [{ loader: "style-loader" }, { loader: "css-loader" }],
  9. },
  10. {
  11. test: /\.scss$/,
  12. use: [
  13. { loader: "style-loader" },
  14. { loader: "css-loader" },
  15. { loader: "sass-loader" },
  16. ],
  17. },
  18. {
  19. test: /\.(woff|woff2|eot|ttf|otf)$/i,
  20. type: "asset/resource",
  21. },
  22. {
  23. test: /\.(png|jpg|jpeg|gif)$/i,
  24. type: "asset/resource",
  25. },
  26. {
  27. test: /\.svg$/,
  28. use: [
  29. {
  30. loader: "@svgr/webpack",
  31. options: {
  32. prettier: false,
  33. svgo: false,
  34. svgoConfig: {
  35. plugins: [{ removeViewBox: false }],
  36. },
  37. titleProp: true,
  38. ref: true,
  39. },
  40. },
  41. ],
  42. }
  43. );
  44. export const rendererConfig: Configuration = {
  45. module: {
  46. rules,
  47. },
  48. plugins,
  49. resolve: {
  50. extensions: [".js", ".ts", ".jsx", ".tsx", ".css", ".scss"],
  51. alias: {
  52. "@": path.join(__dirname, "../src"),
  53. "@renderer": path.join(__dirname, "../src/renderer"),
  54. "@renderer-lrc": path.join(__dirname, "../src/renderer-lrc"),
  55. "@shared": path.join(__dirname, "../src/shared")
  56. },
  57. },
  58. externals: process.platform !== "darwin" ? ["fsevents"] : undefined,
  59. };