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