index.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. const path = require("path");
  2. const config = {
  3. projectName: "taro-pet",
  4. date: "2022-12-17",
  5. alias: {
  6. "@": path.resolve(__dirname, "../src"),
  7. },
  8. designWidth: 750,
  9. deviceRatio: {
  10. 640: 2.34 / 2,
  11. 750: 1,
  12. 828: 1.81 / 2,
  13. },
  14. sourceRoot: "src",
  15. outputRoot: "dist",
  16. plugins: [],
  17. sass: {
  18. resource: [
  19. path.resolve(__dirname, "..", "src/style/variable.scss"),
  20. path.resolve(__dirname, "..", "src/style/mixin.scss"),
  21. ],
  22. },
  23. defineConstants: {},
  24. copy: {
  25. patterns: [],
  26. options: {},
  27. },
  28. framework: "react",
  29. compiler: "webpack5",
  30. cache: {
  31. enable: false, // Webpack 持久化缓存配置,建议开启。默认配置请参考:https://docs.taro.zone/docs/config-detail#cache
  32. },
  33. mini: {
  34. postcss: {
  35. pxtransform: {
  36. enable: true,
  37. config: {},
  38. },
  39. url: {
  40. enable: true,
  41. config: {
  42. limit: 1024, // 设定转换尺寸上限
  43. },
  44. },
  45. cssModules: {
  46. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  47. config: {
  48. namingPattern: "module", // 转换模式,取值为 global/module
  49. generateScopedName: "[name]__[local]___[hash:base64:5]",
  50. },
  51. },
  52. },
  53. enableExtract: true,
  54. miniCssExtractPluginOption: {
  55. //忽略css文件引入顺序
  56. ignoreOrder: true,
  57. },
  58. },
  59. h5: {
  60. publicPath: "/",
  61. staticDirectory: "static",
  62. esnextModules: ["@taroify"],
  63. postcss: {
  64. autoprefixer: {
  65. enable: true,
  66. config: {},
  67. },
  68. cssModules: {
  69. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  70. config: {
  71. namingPattern: "module", // 转换模式,取值为 global/module
  72. generateScopedName: "[name]__[local]___[hash:base64:5]",
  73. },
  74. },
  75. },
  76. },
  77. rn: {
  78. appName: "taroDemo",
  79. postcss: {
  80. cssModules: {
  81. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  82. },
  83. },
  84. },
  85. };
  86. module.exports = function (merge) {
  87. if (process.env.NODE_ENV === "development") {
  88. return merge({}, config, require("./dev"));
  89. }
  90. return merge({}, config, require("./prod"));
  91. };