index.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import { defineConfig, type UserConfigExport } from '@tarojs/cli'
  2. import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin'
  3. import devConfig from './dev'
  4. import prodConfig from './prod'
  5. import version from './version.json'
  6. const CIPluginOpt = {
  7. weapp: {
  8. appid: 'wx46fed622e98fbc6c',
  9. privateKeyPath: 'key/private.wx46fed622e98fbc6c.key'
  10. },
  11. version:version.version,
  12. desc: version.desc
  13. }
  14. // https://taro-docs.jd.com/docs/next/config#defineconfig-辅助函数
  15. export default defineConfig(async (merge, { command, mode }) => {
  16. const baseConfig: UserConfigExport = {
  17. projectName: ' longvideoImerse',
  18. date: '2024-2-7',
  19. designWidth: 750,
  20. deviceRatio: {
  21. 640: 2.34 / 2,
  22. 750: 1,
  23. 375: 2,
  24. 828: 1.81 / 2
  25. },
  26. sourceRoot: 'src',
  27. outputRoot: 'dist',
  28. defineConstants: {
  29. },
  30. copy: {
  31. patterns: [
  32. ],
  33. options: {
  34. }
  35. },
  36. framework: 'react',
  37. compiler: 'webpack5',
  38. cache: {
  39. enable: false // Webpack 持久化缓存配置,建议开启。默认配置请参考:https://docs.taro.zone/docs/config-detail#cache
  40. },
  41. mini: {
  42. postcss: {
  43. pxtransform: {
  44. enable: true,
  45. config: {
  46. }
  47. },
  48. url: {
  49. enable: true,
  50. config: {
  51. limit: 1024 // 设定转换尺寸上限
  52. }
  53. },
  54. cssModules: {
  55. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  56. config: {
  57. namingPattern: 'module', // 转换模式,取值为 global/module
  58. generateScopedName: '[name]__[local]___[hash:base64:5]'
  59. }
  60. }
  61. },
  62. webpackChain(chain) {
  63. chain.resolve.plugin('tsconfig-paths').use(TsconfigPathsPlugin)
  64. }
  65. },
  66. h5: {
  67. publicPath: '/',
  68. staticDirectory: 'static',
  69. output: {
  70. filename: 'js/[name].[hash:8].js',
  71. chunkFilename: 'js/[name].[chunkhash:8].js'
  72. },
  73. miniCssExtractPluginOption: {
  74. ignoreOrder: true,
  75. filename: 'css/[name].[hash].css',
  76. chunkFilename: 'css/[name].[chunkhash].css'
  77. },
  78. postcss: {
  79. autoprefixer: {
  80. enable: true,
  81. config: {}
  82. },
  83. cssModules: {
  84. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  85. config: {
  86. namingPattern: 'module', // 转换模式,取值为 global/module
  87. generateScopedName: '[name]__[local]___[hash:base64:5]'
  88. }
  89. }
  90. },
  91. webpackChain(chain) {
  92. chain.resolve.plugin('tsconfig-paths').use(TsconfigPathsPlugin)
  93. }
  94. },
  95. rn: {
  96. appName: 'taroDemo',
  97. postcss: {
  98. cssModules: {
  99. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  100. }
  101. }
  102. },
  103. plugins: [
  104. ['@tarojs/plugin-mini-ci', CIPluginOpt],
  105. require('path').join(__dirname, '../plugins/PostPreViewQr')
  106. ]
  107. }
  108. if (process.env.NODE_ENV === 'development') {
  109. // 本地开发构建配置(不混淆压缩)
  110. return merge({}, baseConfig, devConfig)
  111. }
  112. // 生产构建配置(默认开启压缩混淆等)
  113. return merge({}, baseConfig, prodConfig)
  114. })