Keep 20261011 hub visuals on home; index only reLaunches to avoid missing page wxss.
Co-authored-by: Cursor <cursoragent@cursor.com>
123 lines
4.2 KiB
TypeScript
123 lines
4.2 KiB
TypeScript
import path from 'path'
|
||
import { defineConfig, type UserConfigExport } from '@tarojs/cli'
|
||
|
||
/** 本目录仅编抖音;勿与上级 weapp / xhs 共享构建目标 */
|
||
const target = 'tt'
|
||
const defaultApi = process.env.TARO_APP_API || 'https://api.nomadro.cn'
|
||
/** 默认 webpack5;`TARO_COMPILER=vite` 走 Vite(保留 webpack 配置) */
|
||
const useVite = String(process.env.TARO_COMPILER || '').toLowerCase() === 'vite'
|
||
|
||
/** 与微信同源视觉:这些表用真实 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)
|
||
|
||
export default defineConfig(async (merge) => {
|
||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||
const { vitePostCopySizePlugin } = require('../scripts/post-copy-size-plugin')
|
||
|
||
const baseConfig: UserConfigExport = {
|
||
projectName: 'nomadro-tt',
|
||
date: '2026-3-30',
|
||
designWidth: 750,
|
||
deviceRatio: {
|
||
640: 2.34 / 2,
|
||
750: 1,
|
||
375: 2,
|
||
828: 1.81 / 2,
|
||
},
|
||
sourceRoot: '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://nomadweb.nomadro.com/api/v1',
|
||
),
|
||
TARO_APP_GATEWAY: JSON.stringify(
|
||
process.env.TARO_APP_GATEWAY || process.env.TARO_APP_API || defaultApi,
|
||
),
|
||
TARO_APP_TARGET: JSON.stringify(target),
|
||
},
|
||
copy: {
|
||
patterns: [
|
||
{ from: 'src/assets/', to: 'assets/' },
|
||
{ from: path.resolve(__dirname, '..', 'src', 'public', 'icons'), to: 'icons' },
|
||
{
|
||
from: path.resolve(__dirname, '..', 'src', 'packageBook', 'assets', 'book-images'),
|
||
to: 'packageBook/assets/book-images',
|
||
},
|
||
],
|
||
options: {},
|
||
},
|
||
framework: 'react',
|
||
compiler: useVite
|
||
? {
|
||
type: 'vite',
|
||
vitePlugins: [vitePostCopySizePlugin()],
|
||
}
|
||
: {
|
||
type: 'webpack5',
|
||
prebundle: { enable: false },
|
||
},
|
||
cache: { enable: !useVite },
|
||
alias: {
|
||
'@': path.resolve(__dirname, '..', 'src'),
|
||
},
|
||
modifyWebpackChain(chain) {
|
||
if (useVite) return
|
||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||
const NomadroPostCopySize = require('../scripts/post-copy-size-plugin')
|
||
chain.plugin('nomadro-copy-icons').use(CopyWebpackPlugin, [
|
||
{
|
||
patterns: [
|
||
{
|
||
from: path.resolve(__dirname, '..', 'src', 'public', 'icons'),
|
||
to: 'icons',
|
||
noErrorOnMissing: true,
|
||
},
|
||
],
|
||
},
|
||
])
|
||
chain.plugin('nomadro-post-copy-size').use(NomadroPostCopySize)
|
||
},
|
||
modifyViteConfig(viteConfig: { build?: { sourcemap?: boolean | 'inline' | 'hidden' } }) {
|
||
if (!useVite) return
|
||
// 上传体积不含 map
|
||
viteConfig.build = viteConfig.build || {}
|
||
viteConfig.build.sourcemap = false
|
||
},
|
||
mini: {
|
||
enableSourceMap: false,
|
||
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)
|
||
})
|