-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
config/index 无法引入 esm 模块([email protected] 无法编译) #15487
Comments
尝试 weapp 也会有类似的问题,应该是 taro 内部解析配置文件不支持导致的,还没有细看源码 |
遇到同样的问题,大佬们有解决方案吗,"unocss": "^0.59.4",Taro v3.6.28 |
降版本,0.58.9及以下可以 |
Taro@4 也不行... |
简单试了一下,用
import { defineConfig } from '@tarojs/cli'
import { createSwcRegister, getModuleDefaultExport } from '@tarojs/helper'
export default defineConfig(async () => {
createSwcRegister({
only: [(filePath: string) => filePath.includes('@unocss')]
})
// require() 或者 import() 都行
const UnoCSS = getModuleDefaultExport(await import('@unocss/webpack'))
return {
projectName: 'taro-unocss',
deviceRatio: {},
sourceRoot: 'src',
outputRoot: 'dist',
framework: 'vue3',
compiler: {
type: 'webpack5',
prebundle: {
enable: false
}
},
h5: {
webpackChain(chain) {
chain.plugin('unocss').use(UnoCSS())
}
}
}
}) 参考: taro/packages/taro-service/src/Config.ts Lines 54 to 62 in 80a6d56
类似的方法还有 taro/packages/taro-helper/src/utils.ts Lines 656 to 667 in 80a6d56
|
降版本,用0.58.0可以 yarn add -D [email protected] @unocss/[email protected] [email protected] |
更正: 最新版直接使用 |
相关平台
H5
浏览器版本: Chrome 版本 123.0.6312.107(正式版本) (arm64)
使用框架: React
复现步骤
期望结果
正常编译
实际结果
环境信息
补充信息
UnoCSS v0.59.0 只有 ESM 模式
The text was updated successfully, but these errors were encountered: