index.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import { defineConfig, type UserConfigExport } from '@tarojs/cli'
  2. import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin'
  3. import { VueLoaderPlugin } from 'vue-loader'
  4. import { resolve } from 'path' // 添加path导入
  5. import Components from 'unplugin-vue-components/webpack'
  6. import NutUIResolver from '@nutui/auto-import-resolver'
  7. export default defineConfig({
  8. projectName: 'miniprogram-linejoy',
  9. date: '2023-4-3',
  10. designWidth: 375,
  11. deviceRatio: {
  12. 640: 2.34 / 2,
  13. 750: 1,
  14. 828: 1.81 / 2,
  15. 375: 2 / 1
  16. },
  17. sourceRoot: 'src',
  18. outputRoot: 'dist',
  19. plugins: ['@tarojs/plugin-html'],
  20. sass: {
  21. data: `
  22. @import "@nutui/nutui-taro/dist/styles/variables.scss";
  23. @import "src/assets/styles/variables.scss";
  24. @import "src/assets/styles/mixins.scss";
  25. `
  26. },
  27. defineConstants: {
  28. },
  29. copy: {
  30. patterns: [
  31. ],
  32. options: {
  33. }
  34. },
  35. framework: 'vue3',
  36. compiler: 'webpack5',
  37. cache: {
  38. enable: false // Webpack 持久化缓存配置,建议开启,默认配置请参考:https://docs.taro.zone/docs/config-detail#cache
  39. },
  40. mini: {
  41. postcss: {
  42. pxtransform: {
  43. enable: true,
  44. config: {
  45. }
  46. },
  47. url: {
  48. enable: true,
  49. config: {
  50. limit: 1024 // 设定转换尺寸上限
  51. }
  52. },
  53. cssModules: {
  54. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  55. config: {
  56. namingPattern: 'module', // 转换模式,取值为 global/module
  57. generateScopedName: '[name]__[local]___[hash:base64:5]'
  58. }
  59. }
  60. },
  61. webpackChain(chain) {
  62. chain.plugin('unplugin-vue-components').use(Components({
  63. resolvers: [NutUIResolver({taro: true})]
  64. }))
  65. chain.resolve.plugin('tsconfig-paths').use(TsconfigPathsPlugin)
  66. // 为webpack添加路径别名
  67. chain.resolve.alias
  68. .set('@', resolve(__dirname, '..', 'src'))
  69. }
  70. },
  71. h5: {
  72. publicPath: '/',
  73. staticDirectory: 'static',
  74. postcss: {
  75. autoprefixer: {
  76. enable: true,
  77. config: {
  78. }
  79. },
  80. cssModules: {
  81. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  82. config: {
  83. namingPattern: 'module', // 转换模式,取值为 global/module
  84. generateScopedName: '[name]__[local]___[hash:base64:5]'
  85. }
  86. }
  87. },
  88. webpackChain(chain) {
  89. chain.plugin('unplugin-vue-components').use(Components({
  90. resolvers: [NutUIResolver({taro: true})]
  91. }))
  92. chain.resolve.plugin('tsconfig-paths').use(TsconfigPathsPlugin)
  93. // 为webpack添加路径别名
  94. chain.resolve.alias
  95. .set('@', resolve(__dirname, '..', 'src'))
  96. }
  97. }
  98. })