index.js 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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: [
  30. { from: "src/assets/tabbar/", to: "dist/assets/tabbar/" },
  31. { from: "src/assets/js/", to: "dist/assets/js/" },
  32. ],
  33. options: {},
  34. },
  35. framework: "react",
  36. compiler: "webpack4",
  37. alias: {
  38. "@": path.resolve(__dirname, "..", "src"),
  39. },
  40. // mini: {
  41. // postcss: {
  42. // pxtransform: {
  43. // enable: true,
  44. // config: {},
  45. // },
  46. // url: {
  47. // enable: true,
  48. // config: {
  49. // limit: 1024, // 设定转换尺寸上限
  50. // },
  51. // },
  52. // cssModules: {
  53. // enable: true, // 默认为 false,如需使用 css modules 功能,则设为 true
  54. // config: {
  55. // namingPattern: "module", // 转换模式,取值为 global/module
  56. // generateScopedName: "[name]__[local]___[hash:base64:5]",
  57. // },
  58. // },
  59. // },
  60. // },
  61. h5: {
  62. publicPath: "/h5",
  63. // staticDirectory: "static",
  64. // outputDir: "dist",
  65. // uglify:false,
  66. router: {
  67. mode: "hash",
  68. basename:""
  69. },
  70. esnextModules: ["@antmjs"],
  71. postcss: {
  72. autoprefixer: {
  73. enable: true,
  74. config: {},
  75. },
  76. pxtransform: {
  77. enable: true,
  78. config: {
  79. },
  80. },
  81. cssModules: {
  82. enable: true, // 默认为 false,如需使用 css modules 功能,则设为 true
  83. config: {
  84. namingPattern: "module", // 转换模式,取值为 global/module,下文详细说明
  85. generateScopedName: "[name]__[local]___[hash:base64:5]",
  86. },
  87. },
  88. },
  89. devServer: {
  90. proxy: {
  91. "/api2": {
  92. target: url2, // 服务端地址
  93. changeOrigin: true,
  94. pathRewrite: {
  95. "^/api2": "",
  96. },
  97. },
  98. "/api": {
  99. target: url, // 服务端地址
  100. changeOrigin: true,
  101. },
  102. },
  103. },
  104. },
  105. };
  106. if (process.env.NODE_ENV === "development") {
  107. return merge({}, config, devConfig);
  108. }
  109. return merge({}, config, prodConfig);
  110. });