当前位置: 首页 > Web前端 > HTML

芋头项目处理sass适配问题

时间:2023-03-28 17:15:55 HTML

Taro新项目引入sass依赖后,本地项目运行控制台总会报错:'Using/fordivisionoutsideofcalc()isdeprecatedandwillberemovedinDartSass2.0.0.'一次性解决方案:在项目根目录中创建一个deploy。sh文件,在文件内容中加入命令行修复sass不支持Taro项目的问题echo"---===installationdependency===---"yarnadd--devsass-migratorpatch-packagepostinstall-postinstallecho"使用sass-migrator修复问题"./node_modules/.bin/sass-migratordivision./node_modules/taro-ui/dist/style/components/*.scssecho"---===使用patch-package保存这个edit===---"./node_modules/.bin/patch-packagetaro-uiecho"---===以后使用postinstall-postinstall自动运行===---"hasPostinstall=$(grep'"postinstall":'package.json)if[["$hasPostinstall"!=""]];thenecho"确保你的package.json具有以下[script:{\"postinstall\":\"patch-package\",...]"elsescriptLine=$(grep-n'"scripts":{'package.json|cut-d:-f1)newScript=$(sed"${scriptLine}a\\"postinstall\":\"patch-package\","package.json)echo"$newScript">package.jsonecho"done!"fi使用:gitbash,执行shdeploy.sh,控制台会自动修复,然后重启项目运行就不会再报这个错了