Taro新建项目引入sass依赖后本地项目运行控制台一直会报错:
' Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.'

一次解决办法:

项目根目录创建deploy.sh文件,文件内容添加命令行修复sass不支持Taro项目问题

echo "---===installation dependency===---"
yarn add --dev sass-migrator patch-package postinstall-postinstall

echo "use sass-migrator to fix problems"
./node_modules/.bin/sass-migrator division ./node_modules/taro-ui/dist/style/components/*.scss

echo "---===use patch-package to save this edit===---"
./node_modules/.bin/patch-package taro-ui

echo "---===use postinstall-postinstall to automatic operation in the future===---"
hasPostinstall=$(grep '"postinstall":' package.json)
if [[ "$hasPostinstall" != "" ]];then
    echo "Make sure your package.json has following [script:{\"postinstall\": \"patch-package\", ...]"
else
    scriptLine=$(grep -n '"scripts": {' package.json  | cut -d : -f 1)
    newScript=$(sed "${scriptLine}a\    \"postinstall\": \"patch-package\"," package.json)
    echo "$newScript" > package.json
    echo "done!"
fi

使用:git bash,执行sh deploy.sh,控制台会自动修复,然后重启项目后运行就不会再报此错误了


Banshee
124 声望4 粉丝

To die is to die, to live is to suffer