dcloudio / uni-preset-vue

uni-app preset for vue
Apache License 2.0
300 stars 116 forks source link

vite-ts,按照 tailwindcss 官方的vite-vue引入方式,无法自动引入postcss的插件需要手动引入,且编译为 mp-weixin 报错 unexpected token "*" #91

Closed seepine closed 10 months ago

seepine commented 10 months ago

vite.config.ts

export default defineConfig({
  plugins: [ uni() ],
  css: {
    postcss: {
      // 必须手动引入
      plugins: [require('tailwindcss'), require('autoprefixer')]
    }
  }
})

编译后会有*选择器,而小程序不支持

[ WXSS 文件编译错误] ./app.wxss
 unexpected token "*"
   5 | 2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)
   6 | */
>  7 | *,
     | ^
   8 | ::before,
   9 | ::after {
  10 |   box-sizing: border-box; /* 1 */
at files://app.wxss#7(env: Windows,mp,1.06.2310080; lib: 3.2.1)

image

image

sonofmagic commented 10 months ago

翻这个项目的时候,正好看到你这个问题,

试试这个weapp-tailwindcss

seepine commented 10 months ago

感谢,看了下你这个,功能挺强大,但配置好像有点繁杂 最终使用了这个 https://github.com/uni-helper/vite-plugin-uni-tailwind