index.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import { UnifiedWebpackPluginV5 } from "weapp-tailwindcss/webpack";
  2. const config = {
  3. projectName: "game-discuz",
  4. date: "2025-9-2",
  5. designWidth: 375,
  6. deviceRatio: {
  7. 640: 2.34 / 2,
  8. 750: 1,
  9. 828: 1.81 / 2,
  10. 375: 2 / 1,
  11. },
  12. sourceRoot: "src",
  13. outputRoot: "dist",
  14. plugins: ["@tarojs/plugin-html"],
  15. defineConstants: {},
  16. copy: {
  17. patterns: [],
  18. options: {},
  19. },
  20. framework: "react",
  21. compiler: {
  22. type: "webpack5",
  23. prebundle: { enable: false },
  24. },
  25. mini: {
  26. webpackChain(chain, webpack) {
  27. chain.merge({
  28. plugin: {
  29. install: {
  30. plugin: UnifiedWebpackPluginV5,
  31. args: [
  32. {
  33. appType: "taro",
  34. // 下面个配置,会开启 rem -> rpx 的转化
  35. // rem2rpx: true,
  36. injectAdditionalCssVarScope: true,
  37. },
  38. ],
  39. },
  40. },
  41. });
  42. },
  43. postcss: {
  44. pxtransform: {
  45. enable: true,
  46. config: {
  47. selectorBlackList: ["nut-"],
  48. },
  49. },
  50. url: {
  51. enable: true,
  52. config: {
  53. limit: 1024, // 设定转换尺寸上限
  54. },
  55. },
  56. cssModules: {
  57. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  58. config: {
  59. namingPattern: "module", // 转换模式,取值为 global/module
  60. generateScopedName: "[name]__[local]___[hash:base64:5]",
  61. },
  62. },
  63. },
  64. },
  65. h5: {
  66. publicPath: "/",
  67. staticDirectory: "static",
  68. // esnextModules: ['nutui-react'],
  69. postcss: {
  70. pxtransform: {
  71. enable: true,
  72. config: {
  73. selectorBlackList: ["nut-"],
  74. // removeCursorStyle: false,
  75. },
  76. },
  77. autoprefixer: {
  78. enable: true,
  79. config: {},
  80. },
  81. cssModules: {
  82. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  83. config: {
  84. namingPattern: "module", // 转换模式,取值为 global/module
  85. generateScopedName: "[name]__[local]___[hash:base64:5]",
  86. },
  87. },
  88. },
  89. },
  90. };
  91. module.exports = function (merge) {
  92. if (process.env.NODE_ENV === "development") {
  93. return merge({}, config, require("./dev"));
  94. }
  95. return merge({}, config, require("./prod"));
  96. };