index.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import Components from 'unplugin-vue-components/webpack';
  2. import NutUIResolver from '@nutui/nutui-taro/dist/resolver';
  3. const config = {
  4. projectName: 'watermark-miniprogram',
  5. date: '2023-8-6',
  6. designWidth (input) {
  7. if (input?.file?.replace(/\\+/g, '/').indexOf('@nutui') > -1) {
  8. return 375
  9. }
  10. return 750
  11. },
  12. deviceRatio: {
  13. 640: 2.34 / 2,
  14. 750: 1,
  15. 828: 1.81 / 2,
  16. 375: 2 / 1
  17. },
  18. sourceRoot: 'src',
  19. outputRoot: `dist/${process.env.TARO_ENV}`,
  20. plugins: ['@tarojs/plugin-html'],
  21. defineConstants: {
  22. },
  23. copy: {
  24. patterns: [
  25. ],
  26. options: {
  27. }
  28. },
  29. framework: 'vue3',
  30. compiler: {
  31. type: 'webpack5',
  32. prebundle: { enable: false }
  33. },
  34. cache: {
  35. enable: false // Webpack 持久化缓存配置,建议开启。默认配置请参考:https://docs.taro.zone/docs/config-detail#cache
  36. },
  37. sass:{
  38. data: `@import "@nutui/nutui-taro/dist/styles/variables.scss";`
  39. },
  40. mini: {
  41. webpackChain(chain) {
  42. chain.plugin('unplugin-vue-components').use(Components({
  43. resolvers: [NutUIResolver({taro: true})]
  44. }))
  45. },
  46. postcss: {
  47. pxtransform: {
  48. enable: true,
  49. config: {
  50. // selectorBlackList: ['nut-']
  51. }
  52. },
  53. url: {
  54. enable: true,
  55. config: {
  56. limit: 1024 // 设定转换尺寸上限
  57. }
  58. },
  59. cssModules: {
  60. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  61. config: {
  62. namingPattern: 'module', // 转换模式,取值为 global/module
  63. generateScopedName: '[name]__[local]___[hash:base64:5]'
  64. }
  65. }
  66. }
  67. },
  68. h5: {
  69. webpackChain(chain) {
  70. chain.plugin('unplugin-vue-components').use(Components({
  71. resolvers: [NutUIResolver({taro: true})]
  72. }))
  73. },
  74. publicPath: '/',
  75. staticDirectory: 'static',
  76. esnextModules: ['nutui-taro', 'icons-vue-taro'],
  77. postcss: {
  78. autoprefixer: {
  79. enable: true,
  80. config: {
  81. }
  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. }
  92. }
  93. module.exports = function (merge) {
  94. if (process.env.NODE_ENV === 'development') {
  95. return merge({}, config, require('./dev'))
  96. }
  97. return merge({}, config, require('./prod'))
  98. }