chore: initialize WanderQ MiniAPP 2.0 repository

This commit is contained in:
inman
2026-07-23 15:48:34 +08:00
commit b4c0a1c516
93 changed files with 53525 additions and 0 deletions

View File

@@ -0,0 +1 @@
export default {};

View File

@@ -0,0 +1,76 @@
import path from "node:path";
import { fileURLToPath } from "node:url";
import { defineConfig, type UserConfigExport } from "@tarojs/cli";
const appRoot = path.resolve(fileURLToPath(new URL("..", import.meta.url)));
const DEFAULT_API_BASE_URL = "https://biz.wanderqtrip.com/api";
class StripWxssWebpackBannersPlugin {
apply(compiler: any) {
compiler.hooks.thisCompilation.tap("StripWxssWebpackBannersPlugin", (compilation: any) => {
compilation.hooks.processAssets.tap(
{
name: "StripWxssWebpackBannersPlugin",
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,
},
(assets: Record<string, any>) => {
for (const [filename, asset] of Object.entries(assets)) {
if (!filename.endsWith(".wxss")) continue;
const source = asset.source().toString();
const cleaned = source.replace(/^\/\*![\s\S]*?\*\/\s*/, "");
if (cleaned !== source) {
compilation.updateAsset(filename, new compiler.webpack.sources.RawSource(cleaned));
}
}
},
);
});
}
}
const baseConfig: UserConfigExport = {
projectName: "wanqu-mini-program",
date: "2026-07-22",
designWidth: 750,
deviceRatio: {
640: 2.34 / 2,
750: 1,
828: 1.81 / 2,
},
sourceRoot: "src",
outputRoot: "dist",
framework: "react",
compiler: "webpack5",
defineConstants: {
"process.env.TARO_APP_API_BASE_URL": JSON.stringify(process.env.TARO_APP_API_BASE_URL || DEFAULT_API_BASE_URL),
"process.env.TARO_APP_H5_URL": JSON.stringify(process.env.TARO_APP_H5_URL ?? "http://127.0.0.1:5173"),
},
alias: {
// Taro 4.2.1 requires React 18. Keep the mini program's renderer on the
// workspace-local React copy while H5/admin can continue using React 19.
"react$": path.join(appRoot, "node_modules/react"),
},
mini: {
webpackChain: (chain) => {
chain.plugin("strip-wxss-webpack-banners").use(StripWxssWebpackBannersPlugin);
},
postcss: {
pxtransform: { enable: true },
url: { enable: true },
cssModules: { enable: false },
},
},
h5: {
publicPath: "/",
staticDirectory: "static",
},
};
export default defineConfig(async (merge, _env) => {
if (process.env.NODE_ENV === "development") {
return merge({}, baseConfig, {
mini: { debugReact: true, enableSourceMap: false },
});
}
return merge({}, baseConfig);
});

View File

@@ -0,0 +1 @@
export default {};