import { defineConfig } from "@tarojs/cli"; const path = require("path"); import devConfig from "./dev"; import prodConfig from "./prod"; export default defineConfig(async (merge, { command, mode }) => { const config = { projectName: "civilized-miniapp", date: "2024-03-21", designWidth: 750, deviceRatio: { 640: 2.34 / 2, 750: 1, 828: 1.81 / 2, }, 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: "/", staticDirectory: "static", outputDir: 'dist', router : { mode : "hash", // base : "./" }, // output: { // filename: "js/[name].[hash:8].js", // chunkFilename: "js/[name].[chunkhash:8].js", // }, miniCssExtractPluginOption: { ignoreOrder: true, filename: "css/[name].[hash].css", chunkFilename: "css/[name].[chunkhash].css", }, postcss: { autoprefixer: { enable: true, config: {}, }, cssModules: { enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true config: { namingPattern: "module", // 转换模式,取值为 global/module generateScopedName: "[name]__[local]___[hash:base64:5]", }, }, }, // devServer: { // host: "0.0.0.0", // // port: , // proxy: { // "/api": { // target: "http://127.0.0.1:9087", // 服务端地址 // pathRewrite: { // '/api': '' // }, // changeOrigin: true, // }, // }, // }, }, }; if (process.env.NODE_ENV === "development") { return merge({}, config, devConfig); } return merge({}, config, prodConfig); });