import { defineConfig } from "@tarojs/cli"; const path = require("path"); import devConfig from "./dev"; import prodConfig from "./prod"; const url = "http://localhost:9087"; const url2 = "https://apis.map.qq.com"; export default defineConfig(async (merge, { command, mode }) => { const config = { projectName: "civilized-miniapp", date: "2024-03-21", designWidth(input) { console.log("---->", input?.file); // if (input?.file.replace(/\\+/g, '/').indexOf('@antmjs/vantui') > -1) { // return 750 // } return 750; }, deviceRatio: { 640: 2.34 / 2, 750: 1, 828: 1.81 / 2, 375: 2 / 1, }, sourceRoot: "src", outputRoot: "dist", plugins: [], defineConstants: {}, copy: { patterns: [{ from: "src/assets/tabbar/", to: "dist/assets/tabbar/" }], options: {}, }, framework: "react", compiler: "webpack4", alias: { "@": path.resolve(__dirname, "..", "src"), }, // mini: { // postcss: { // pxtransform: { // enable: true, // config: {}, // }, // url: { // enable: true, // config: { // limit: 1024, // 设定转换尺寸上限 // }, // }, // cssModules: { // enable: true, // 默认为 false,如需使用 css modules 功能,则设为 true // config: { // namingPattern: "module", // 转换模式,取值为 global/module // generateScopedName: "[name]__[local]___[hash:base64:5]", // }, // }, // }, // }, h5: { publicPath: "/h5", // staticDirectory: "static", // outputDir: "dist", // uglify:false, router: { mode: "browser", basename:"/h5" }, esnextModules: ["@antmjs"], postcss: { autoprefixer: { enable: true, config: {}, }, pxtransform: { enable: true, config: { }, }, cssModules: { enable: true, // 默认为 false,如需使用 css modules 功能,则设为 true config: { namingPattern: "module", // 转换模式,取值为 global/module,下文详细说明 generateScopedName: "[name]__[local]___[hash:base64:5]", }, }, }, devServer: { proxy: { "/api2": { target: url2, // 服务端地址 changeOrigin: true, pathRewrite: { "^/api2": "", }, }, "/api": { target: url, // 服务端地址 changeOrigin: true, }, }, }, }, }; if (process.env.NODE_ENV === "development") { return merge({}, config, devConfig); } return merge({}, config, prodConfig); });