123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- import { defineConfig } from "@tarojs/cli";
-
- import devConfig from "./dev";
- import prodConfig from "./prod";
-
- // eslint-disable-next-line import/no-commonjs
- const path = require("path");
-
- 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,
- },
- // jsMinimizer: 'terser',
- // terser: {
- // enable: false,
- // },
- sourceRoot: "src",
- outputRoot: "dist",
- plugins: [],
- defineConstants: {},
- copy: {
- patterns: [
- { from: "src/assets/tabbar/", to: "dist/assets/tabbar/" },
- { from: "src/assets/js/", to: "dist/assets/js/" },
- ],
- options: {},
- },
- framework: "react",
- compiler: "webpack4",
- alias: {
- "@": path.resolve(__dirname, "..", "src"),
- "@antmjs/vantui/es/field/index": path.resolve(__dirname, "..", "node_modules/@antmjs/vantui/es/field/index.js"),
- "@antmjs/vantui/es/field/index.css": path.resolve(__dirname, "..", "node_modules/@antmjs/vantui/es/field/index.less"),
- },
-
- // 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: "hash",
- basename:""
- },
- 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,
- },
-
- },
- },
- webpackChain(chain, webpack) {
- chain.merge({
- mode: "development",
- })
- },
- },
- };
- if (process.env.NODE_ENV === "development") {
- return merge({}, config, devConfig);
- }
- return merge({}, config, prodConfig);
- });
|