Files
gongxue-base/apps/taro/config/index.ts
2026-07-01 02:37:43 +08:00

68 lines
1.5 KiB
TypeScript

import type { UserConfigExport } from '@tarojs/cli';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const portal = process.env.TARO_APP_PORTAL || 'student';
const configDir = path.dirname(fileURLToPath(import.meta.url));
const distDirByPortal: Record<string, string> = {
student: 'dist/h5-student',
'tenant-admin': 'dist/h5-tenant-admin',
'platform-admin': 'dist/h5-platform-admin',
};
const outputRoot = distDirByPortal[portal] || distDirByPortal.student;
export default {
projectName: 'tiku-saas-taro',
date: '2026-06-29',
designWidth: 750,
deviceRatio: {
640: 2.34 / 2,
750: 1,
828: 1.81 / 2,
},
sourceRoot: 'src',
outputRoot,
framework: 'react',
compiler: {
type: 'webpack5',
prebundle: {
enable: false,
},
},
alias: {
'@': path.resolve(configDir, '..', 'src'),
},
defineConstants: {},
copy: {
patterns: [
{
from: path.resolve(configDir, '..', 'src', 'assets'),
to: path.resolve(configDir, '..', outputRoot, 'assets'),
},
],
options: {},
},
h5: {
publicPath: '/',
staticDirectory: 'static',
output: {
filename: 'js/[name].[contenthash:8].js',
chunkFilename: 'js/[name].[contenthash:8].js',
},
router: {
mode: 'browser',
},
},
mini: {
postcss: {
pxtransform: {
enable: true,
config: {},
},
cssModules: {
enable: false,
},
},
},
} satisfies UserConfigExport;