programape123
programape123
  • 发布:2023-03-16 18:55
  • 更新:2023-03-27 16:30
  • 阅读:358

【报Bug】uniapp 引入 windiCSS 错误

分类:uni-app

产品分类: uniapp/H5

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: window10

HBuilderX类型: 正式

HBuilderX版本号: 3.7.3

浏览器平台: Chrome

浏览器版本: 360极速浏览器

项目创建方式: HBuilderX

示例代码:

import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import commonjs from '@rollup/plugin-commonjs'
import windiCSS from 'vite-plugin-windicss'
import miniProgramTailwind from '@dcasia/mini-program-tailwind-webpack-plugin/rollup'

export default defineConfig({
plugins: [
uni(),
commonjs(),
windiCSS({
scan: {
dirs: ['.'], // all files in the cwd
fileExtensions: ['vue', 'js', 'ts'] // also enabled scanning for js/ts
}
}),
miniProgramTailwind()
],
server: {
host: '0.0.0.0',
port: 8000
},
build: {
minify: 'terser',
terserOptions: {
compress: {
drop_console: true
}
}
}
})

操作步骤:
import { defineConfig } from 'vite'  
import uni from '@dcloudio/vite-plugin-uni'  
import commonjs from '@rollup/plugin-commonjs'  
import windiCSS from 'vite-plugin-windicss'  
import miniProgramTailwind from '@dcasia/mini-program-tailwind-webpack-plugin/rollup'  

export default defineConfig({  
    plugins: [  
        uni(),  
        commonjs(),  
        windiCSS({  
            scan: {  
                dirs: ['.'], // all files in the cwd  
                fileExtensions: ['vue', 'js', 'ts'] // also enabled scanning for js/ts  
            }  
        }),  
        miniProgramTailwind()  
    ],  
    server: {  
        host: '0.0.0.0',  
        port: 8000  
    },  
    build: {  
        minify: 'terser',  
        terserOptions: {  
            compress: {  
                drop_console: true  
            }  
        }  
    }  
})  

预期结果:

正常输出

实际结果:

[vite] Cannot read properties of undefined (reading 'length')

bug描述:

引入 windiCSS 在vite.config.ts 中配置之后 编译h5 出现该错误: [vite] Cannot read properties of undefined (reading 'length')

2023-03-16 18:55 负责人:无 分享
已邀请:
DCloud_UNI_GSQ

DCloud_UNI_GSQ

https://github.com/dcloudio/uni-app/issues/3091

要回复问题请先登录注册