feat(config): enhance development configuration and update platform support
- Added `devServer` configuration for H5 platform to allow file system access. - Updated platform type to include 'h5' in the factory. - Adjusted icon paths in app configuration for consistency. - Cleaned up code formatting and removed deprecated Redux store documentation.
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import { defineConfig, type UserConfigExport } from '@tarojs/cli'
|
||||
import { UnifiedWebpackPluginV5 } from 'weapp-tailwindcss/webpack'
|
||||
import { defineConfig, type UserConfigExport } from '@tarojs/cli';
|
||||
import { UnifiedWebpackPluginV5 } from 'weapp-tailwindcss/webpack';
|
||||
|
||||
import devConfig from './dev'
|
||||
import prodConfig from './prod'
|
||||
import devConfig from './dev';
|
||||
import prodConfig from './prod';
|
||||
|
||||
// https://taro-docs.jd.com/docs/next/config#defineconfig-辅助函数
|
||||
export default defineConfig<'vite'>(async (merge) => {
|
||||
export default defineConfig<'vite'>(async merge => {
|
||||
// 不同平台的 appId 配置
|
||||
const appIds = {
|
||||
weapp: process.env.TARO_APP_ID_WEAPP || 'your-weapp-appid',
|
||||
@@ -13,8 +13,8 @@ export default defineConfig<'vite'>(async (merge) => {
|
||||
alipay: process.env.TARO_APP_ID_ALIPAY || 'your-alipay-appid',
|
||||
swan: process.env.TARO_APP_ID_SWAN || 'your-swan-appid',
|
||||
qq: process.env.TARO_APP_ID_QQ || 'your-qq-appid',
|
||||
jd: process.env.TARO_APP_ID_JD || 'your-jd-appid'
|
||||
}
|
||||
jd: process.env.TARO_APP_ID_JD || 'your-jd-appid',
|
||||
};
|
||||
|
||||
const baseConfig: UserConfigExport<'vite'> = {
|
||||
projectName: 'bw-mini-app',
|
||||
@@ -24,24 +24,20 @@ export default defineConfig<'vite'>(async (merge) => {
|
||||
640: 2.34 / 2,
|
||||
750: 1,
|
||||
375: 2,
|
||||
828: 1.81 / 2
|
||||
828: 1.81 / 2,
|
||||
},
|
||||
sourceRoot: 'src',
|
||||
outputRoot: process.env.TARO_ENV ? `dist/${process.env.TARO_ENV}` : 'dist',
|
||||
plugins: [
|
||||
"@tarojs/plugin-generator"
|
||||
],
|
||||
defineConstants: {
|
||||
},
|
||||
plugins: ['@tarojs/plugin-generator'],
|
||||
defineConstants: {},
|
||||
copy: {
|
||||
patterns: [
|
||||
{
|
||||
from: 'src/assets/icons/',
|
||||
to: 'assets/icons/'
|
||||
}
|
||||
to: 'assets/icons/',
|
||||
},
|
||||
],
|
||||
options: {
|
||||
}
|
||||
options: {},
|
||||
},
|
||||
framework: 'react',
|
||||
compiler: 'vite',
|
||||
@@ -49,57 +45,57 @@ export default defineConfig<'vite'>(async (merge) => {
|
||||
postcss: {
|
||||
pxtransform: {
|
||||
enable: true,
|
||||
config: {
|
||||
|
||||
}
|
||||
config: {},
|
||||
},
|
||||
cssModules: {
|
||||
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
|
||||
config: {
|
||||
namingPattern: 'module', // 转换模式,取值为 global/module
|
||||
generateScopedName: '[name]__[local]___[hash:base64:5]'
|
||||
}
|
||||
}
|
||||
generateScopedName: '[name]__[local]___[hash:base64:5]',
|
||||
},
|
||||
},
|
||||
},
|
||||
webpackChain(chain) {
|
||||
chain.merge({
|
||||
plugin: {
|
||||
install: {
|
||||
plugin: UnifiedWebpackPluginV5,
|
||||
args: [{
|
||||
appType: 'taro',
|
||||
// 下面个配置,会开启 rem -> rpx 的转化
|
||||
rem2rpx: true
|
||||
}]
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
args: [
|
||||
{
|
||||
appType: 'taro',
|
||||
// 下面个配置,会开启 rem -> rpx 的转化
|
||||
rem2rpx: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
// 小程序平台特定配置
|
||||
weapp: {
|
||||
outputRoot: 'dist/weapp',
|
||||
appId: appIds.weapp
|
||||
appId: appIds.weapp,
|
||||
},
|
||||
tt: {
|
||||
outputRoot: 'dist/tt',
|
||||
appId: appIds.tt
|
||||
appId: appIds.tt,
|
||||
},
|
||||
alipay: {
|
||||
outputRoot: 'dist/alipay',
|
||||
appId: appIds.alipay
|
||||
appId: appIds.alipay,
|
||||
},
|
||||
swan: {
|
||||
outputRoot: 'dist/swan',
|
||||
appId: appIds.swan
|
||||
appId: appIds.swan,
|
||||
},
|
||||
qq: {
|
||||
outputRoot: 'dist/qq',
|
||||
appId: appIds.qq
|
||||
appId: appIds.qq,
|
||||
},
|
||||
jd: {
|
||||
outputRoot: 'dist/jd',
|
||||
appId: appIds.jd
|
||||
appId: appIds.jd,
|
||||
},
|
||||
h5: {
|
||||
publicPath: '/',
|
||||
@@ -108,20 +104,20 @@ export default defineConfig<'vite'>(async (merge) => {
|
||||
miniCssExtractPluginOption: {
|
||||
ignoreOrder: true,
|
||||
filename: 'css/[name].[hash].css',
|
||||
chunkFilename: 'css/[name].[chunkhash].css'
|
||||
chunkFilename: 'css/[name].[chunkhash].css',
|
||||
},
|
||||
postcss: {
|
||||
autoprefixer: {
|
||||
enable: true,
|
||||
config: {}
|
||||
config: {},
|
||||
},
|
||||
cssModules: {
|
||||
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
|
||||
config: {
|
||||
namingPattern: 'module', // 转换模式,取值为 global/module
|
||||
generateScopedName: '[name]__[local]___[hash:base64:5]'
|
||||
}
|
||||
}
|
||||
generateScopedName: '[name]__[local]___[hash:base64:5]',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
rn: {
|
||||
@@ -129,17 +125,17 @@ export default defineConfig<'vite'>(async (merge) => {
|
||||
postcss: {
|
||||
cssModules: {
|
||||
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
process.env.BROWSERSLIST_ENV = process.env.NODE_ENV
|
||||
process.env.BROWSERSLIST_ENV = process.env.NODE_ENV;
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
// 本地开发构建配置(不混淆压缩)
|
||||
return merge({}, baseConfig, devConfig)
|
||||
return merge({}, baseConfig, devConfig);
|
||||
}
|
||||
// 生产构建配置(默认开启压缩混淆等)
|
||||
return merge({}, baseConfig, prodConfig)
|
||||
})
|
||||
return merge({}, baseConfig, prodConfig);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user