Refresh audience/admin UX, ntfy/track, social paths, and replace ebook chapters with the expanded catalog; keep local SQLite and one-off probe scripts out of tree. Co-authored-by: Cursor <cursoragent@cursor.com>
153 lines
5.7 KiB
TypeScript
153 lines
5.7 KiB
TypeScript
import path from 'path'
|
||
import { defineConfig, type UserConfigExport } from '@tarojs/cli'
|
||
|
||
/** WeChat weapp only; sourceRoot shares ../h5/src */
|
||
const target = process.env.TARO_APP_TARGET || process.env.TARO_ENV || 'weapp'
|
||
if (target === 'h5') {
|
||
throw new Error(
|
||
'[nomadro] H5 is apps/miniprogram/h5 — use: pnpm --dir h5 dev',
|
||
)
|
||
}
|
||
|
||
const defaultApi = process.env.TARO_APP_API || 'https://api.nomadro.cn'
|
||
const h5Src = path.resolve(__dirname, '..', '..', 'h5', 'src')
|
||
|
||
/** 与门户同源视觉:这些表用真实 px/rem,禁止 750→rpx */
|
||
const pxExclude = (file: string) =>
|
||
/[\\/]styles[\\/]hub\.scss/.test(file) ||
|
||
/[\\/]styles[\\/]navmini\.scss/.test(file) ||
|
||
/[\\/]styles[\\/]ebook-cover\.scss/.test(file) ||
|
||
/[\\/]styles[\\/]community\.scss/.test(file) ||
|
||
/[\\/]styles[\\/]community-navbar\.scss/.test(file) ||
|
||
/[\\/]styles[\\/]portal-nav-h5\.scss/.test(file) ||
|
||
/[\\/]styles[\\/]vip-landing\.scss/.test(file) ||
|
||
/[\\/]styles[\\/]h5-theme\.scss/.test(file) ||
|
||
/[\\/]styles[\\/]weapp-parity\.scss/.test(file) ||
|
||
/[\\/]styles[\\/]page-rem\.scss/.test(file) ||
|
||
/[\\/]pages[\\/]home[\\/]index\.scss/.test(file) ||
|
||
/[\\/]pages[\\/]index[\\/]index\.scss/.test(file) ||
|
||
/[\\/]pages[\\/]nav[\\/]index\.scss/.test(file) ||
|
||
/[\\/]pages[\\/]book[\\/]index\.scss/.test(file) ||
|
||
/[\\/]pages[\\/]community[\\/]index\.scss/.test(file) ||
|
||
/[\\/]pages[\\/]vip[\\/]index\.scss/.test(file) ||
|
||
/[\\/]pages[\\/]vip-account[\\/]index\.scss/.test(file) ||
|
||
/[\\/]pages[\\/]vip-course[\\/]index\.scss/.test(file) ||
|
||
/[\\/]pages[\\/]vip-lesson[\\/]index\.scss/.test(file) ||
|
||
/[\\/]pages[\\/]vip-ebook[\\/]index\.scss/.test(file) ||
|
||
/[\\/]pages[\\/]vip-store[\\/]index\.scss/.test(file) ||
|
||
/[\\/]pages[\\/]vip-store-detail[\\/]index\.scss/.test(file) ||
|
||
/[\\/]pages[\\/]vip-store-orders[\\/]index\.scss/.test(file) ||
|
||
/[\\/]pages[\\/]vip-memo[\\/]index\.scss/.test(file) ||
|
||
/[\\/]pages[\\/]vip-memo-detail[\\/]index\.scss/.test(file) ||
|
||
/[\\/]components[\\/]DebugFab\.scss/.test(file) ||
|
||
/[\\/]components[\\/]OaPresenceChip\.scss/.test(file) ||
|
||
/[\\/]components[\\/]WechatOaModal\.scss/.test(file) ||
|
||
/[\\/]components[\\/]VipLoginModal\.scss/.test(file) ||
|
||
/[\\/]components[\\/]NetdiskShareModal\.scss/.test(file) ||
|
||
/[\\/]styles[\\/]social-next[\\/]/.test(file) ||
|
||
/[\\/]styles[\\/]social\.scss/.test(file) ||
|
||
/[\\/]styles[\\/]social-weapp\.scss/.test(file) ||
|
||
/[\\/]styles[\\/]social-next[\\/]weapp-bridge\.scss/.test(file) ||
|
||
/[\\/]pages[\\/]social[\\/]/.test(file)
|
||
|
||
export default defineConfig(async (merge) => {
|
||
const baseConfig: UserConfigExport = {
|
||
projectName: 'nomadro-weapp',
|
||
date: '2026-3-30',
|
||
designWidth: 750,
|
||
deviceRatio: {
|
||
640: 2.34 / 2,
|
||
750: 1,
|
||
375: 2,
|
||
828: 1.81 / 2,
|
||
},
|
||
sourceRoot: '../h5/src',
|
||
outputRoot: 'dist',
|
||
plugins: ['@tarojs/plugin-framework-react'],
|
||
defineConstants: {
|
||
TARO_APP_API: JSON.stringify(defaultApi),
|
||
TARO_APP_COMMUNITY_API: JSON.stringify(
|
||
process.env.TARO_APP_COMMUNITY_API || 'https://api.nomadro.cn/api/v1',
|
||
),
|
||
TARO_APP_GATEWAY: JSON.stringify(
|
||
process.env.TARO_APP_GATEWAY || process.env.TARO_APP_API || defaultApi,
|
||
),
|
||
TARO_APP_TARGET: JSON.stringify('weapp'),
|
||
},
|
||
copy: {
|
||
patterns: [
|
||
{
|
||
from: path.join(h5Src, 'assets'),
|
||
to: 'assets/',
|
||
ignore: ['**/.DS_Store', '**/icons/**'],
|
||
},
|
||
],
|
||
options: {},
|
||
},
|
||
framework: 'react',
|
||
compiler: {
|
||
type: 'webpack5',
|
||
prebundle: { enable: false },
|
||
},
|
||
// 关 persistent cache:避免反复刷「Can't resolve weapp/src/app.config」假报错
|
||
cache: { enable: false },
|
||
alias: {
|
||
'@': h5Src,
|
||
},
|
||
modifyWebpackChain(chain) {
|
||
const weappNm = path.resolve(__dirname, '..', 'node_modules')
|
||
const webpack = require('webpack')
|
||
chain.resolve.modules.prepend(weappNm)
|
||
chain.resolve.alias.set(
|
||
'@tarojs/plugin-platform-weapp',
|
||
path.join(weappNm, '@tarojs/plugin-platform-weapp'),
|
||
)
|
||
// game:weapp 用无 three 的 stub,避免 ~2MB
|
||
chain.resolve.alias.set(
|
||
path.join(h5Src, 'modules/game/nomad3d'),
|
||
path.join(h5Src, 'modules/game/nomad3d.weapp.ts'),
|
||
)
|
||
chain.resolve.alias.set(
|
||
'@/modules/game/nomad3d',
|
||
path.join(h5Src, 'modules/game/nomad3d.weapp.ts'),
|
||
)
|
||
chain.plugin('ignore-three').use(webpack.IgnorePlugin, [
|
||
{ resourceRegExp: /^three$/ },
|
||
])
|
||
// 导航图标不进包:运行时用 https://nomadro.cn/icons(代码质量:图片合计≤200K)
|
||
// watch 完成后补缺失页面 wxss(home/index 样式进 common 时 Taro 不落文件)
|
||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||
const { EnsurePageWxssPlugin } = require(path.join(
|
||
__dirname,
|
||
'..',
|
||
'scripts',
|
||
'ensure-page-wxss-plugin.cjs',
|
||
))
|
||
const distRoot = path.resolve(__dirname, '..', 'dist')
|
||
// 补缺页 wxss + 清洗 social Next CSS 里 WXSS 不支持的 @layer/:has/:is
|
||
chain.plugin('ensure-page-wxss').use(EnsurePageWxssPlugin, [
|
||
{ pagesRoot: path.join(distRoot, 'pages'), distRoot },
|
||
])
|
||
},
|
||
mini: {
|
||
enableSourceMap: false,
|
||
/** 分包独占依赖不进主包 common(压主包 ≤1.5MB) */
|
||
optimizeMainPackage: {
|
||
enable: true,
|
||
},
|
||
postcss: {
|
||
pxtransform: {
|
||
enable: true,
|
||
config: { exclude: pxExclude },
|
||
},
|
||
cssModules: { enable: false },
|
||
},
|
||
},
|
||
}
|
||
|
||
if (process.env.NODE_ENV === 'development') {
|
||
return merge({}, baseConfig, { logger: { quiet: false, stats: true } })
|
||
}
|
||
return merge({}, baseConfig)
|
||
})
|