index.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import {UnifiedWebpackPluginV5} from 'weapp-tailwindcss-webpack-plugin';
  2. import {resolve} from 'path';
  3. const config = {
  4. projectName: 'shougang-wms-mini',
  5. date: '2023-4-17',
  6. designWidth: 375,
  7. deviceRatio: {
  8. 640: 2.34 / 2,
  9. 750: 1,
  10. 828: 1.81 / 2,
  11. 375: 2 / 1,
  12. },
  13. sourceRoot: 'src',
  14. outputRoot: 'dist',
  15. plugins: ['@tarojs/plugin-html'],
  16. defineConstants: {},
  17. copy: {
  18. patterns: [],
  19. options: {},
  20. },
  21. framework: 'react',
  22. compiler: 'webpack5',
  23. cache: {
  24. enable: false, // Webpack 持久化缓存配置,建议开启。默认配置请参考:https://docs.taro.zone/docs/config-detail#cache
  25. },
  26. alias: {
  27. '@styles': resolve(__dirname, '..', 'src/styles'),
  28. '@assets': resolve(__dirname, '..', 'src/assets'),
  29. '@routes': resolve(__dirname, '..', 'src/routes'),
  30. '@apis': resolve(__dirname, '..', 'src/apis'),
  31. '@components': resolve(__dirname, '..', 'src/components'),
  32. '@hooks': resolve(__dirname, '..', 'src/hooks'),
  33. '@pages': resolve(__dirname, '..', 'src/pages'),
  34. '@stores': resolve(__dirname, '..', 'src/stores'),
  35. '@utils': resolve(__dirname, '..', 'src/utils'),
  36. '@models': resolve(__dirname, '..', 'src/models'),
  37. },
  38. mini: {
  39. miniCssExtractPluginOption: {
  40. ignoreOrder: true,
  41. },
  42. hot: true,
  43. optimizeMainPackage: {
  44. enable: true,
  45. },
  46. webpackChain(chain) {
  47. chain.merge({
  48. plugin: {
  49. install: {
  50. plugin: UnifiedWebpackPluginV5,
  51. args: [
  52. {
  53. appType: 'taro',
  54. },
  55. 'taro',
  56. ],
  57. },
  58. },
  59. });
  60. },
  61. postcss: {
  62. pxtransform: {
  63. enable: false,
  64. config: {
  65. selectorBlackList: ['nut-'],
  66. },
  67. },
  68. url: {
  69. enable: true,
  70. config: {
  71. limit: 1024, // 设定转换尺寸上限
  72. },
  73. },
  74. cssModules: {
  75. enable: true, // 默认为 false,如需使用 css modules 功能,则设为 true
  76. config: {
  77. namingPattern: 'module', // 转换模式,取值为 global/module
  78. generateScopedName: '[local]-[hash:base64:5]',
  79. },
  80. },
  81. },
  82. },
  83. h5: {
  84. publicPath: '/',
  85. staticDirectory: 'static',
  86. // esnextModules: ['nutui-react'],
  87. postcss: {
  88. pxtransform: {
  89. enable: true,
  90. config: {
  91. selectorBlackList: ['nut-'],
  92. },
  93. },
  94. autoprefixer: {
  95. enable: true,
  96. config: {},
  97. },
  98. cssModules: {
  99. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  100. config: {
  101. namingPattern: 'module', // 转换模式,取值为 global/module
  102. generateScopedName: '[name]__[local]___[hash:base64:5]',
  103. },
  104. },
  105. },
  106. },
  107. };
  108. module.exports = function(merge) {
  109. if (process.env.NODE_ENV === 'development') {
  110. return merge({}, config, require('./dev'));
  111. }
  112. return merge({}, config, require('./prod'));
  113. };