index.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import { defineConfig } from "@tarojs/cli";
  2. const path = require("path");
  3. import devConfig from "./dev";
  4. import prodConfig from "./prod";
  5. const url = "http://localhost:9087";
  6. const url2 = "https://apis.map.qq.com";
  7. export default defineConfig(async (merge, { command, mode }) => {
  8. const config = {
  9. projectName: "civilized-miniapp",
  10. date: "2024-03-21",
  11. designWidth(input) {
  12. console.log("---->", input?.file);
  13. // if (input?.file.replace(/\\+/g, '/').indexOf('@antmjs/vantui') > -1) {
  14. // return 750
  15. // }
  16. return 750;
  17. },
  18. deviceRatio: {
  19. 640: 2.34 / 2,
  20. 750: 1,
  21. 828: 1.81 / 2,
  22. 375: 2 / 1,
  23. },
  24. sourceRoot: "src",
  25. outputRoot: "dist",
  26. plugins: [],
  27. defineConstants: {},
  28. copy: {
  29. patterns: [{ from: "src/assets/tabbar/", to: "dist/assets/tabbar/" }],
  30. options: {},
  31. },
  32. framework: "react",
  33. compiler: "webpack4",
  34. alias: {
  35. "@": path.resolve(__dirname, "..", "src"),
  36. },
  37. // mini: {
  38. // postcss: {
  39. // pxtransform: {
  40. // enable: true,
  41. // config: {},
  42. // },
  43. // url: {
  44. // enable: true,
  45. // config: {
  46. // limit: 1024, // 设定转换尺寸上限
  47. // },
  48. // },
  49. // cssModules: {
  50. // enable: true, // 默认为 false,如需使用 css modules 功能,则设为 true
  51. // config: {
  52. // namingPattern: "module", // 转换模式,取值为 global/module
  53. // generateScopedName: "[name]__[local]___[hash:base64:5]",
  54. // },
  55. // },
  56. // },
  57. // },
  58. h5: {
  59. publicPath: "/h5",
  60. // staticDirectory: "static",
  61. // outputDir: "dist",
  62. // uglify:false,
  63. router: {
  64. mode: "browser",
  65. basename:"/h5"
  66. },
  67. esnextModules: ["@antmjs"],
  68. postcss: {
  69. autoprefixer: {
  70. enable: true,
  71. config: {},
  72. },
  73. pxtransform: {
  74. enable: true,
  75. config: {
  76. },
  77. },
  78. cssModules: {
  79. enable: true, // 默认为 false,如需使用 css modules 功能,则设为 true
  80. config: {
  81. namingPattern: "module", // 转换模式,取值为 global/module,下文详细说明
  82. generateScopedName: "[name]__[local]___[hash:base64:5]",
  83. },
  84. },
  85. },
  86. devServer: {
  87. proxy: {
  88. "/api2": {
  89. target: url2, // 服务端地址
  90. changeOrigin: true,
  91. pathRewrite: {
  92. "^/api2": "",
  93. },
  94. },
  95. "/api": {
  96. target: url, // 服务端地址
  97. changeOrigin: true,
  98. },
  99. },
  100. },
  101. },
  102. };
  103. if (process.env.NODE_ENV === "development") {
  104. return merge({}, config, devConfig);
  105. }
  106. return merge({}, config, prodConfig);
  107. });