新搭建的uni-app还是报sass警告,导致打包到40%窗口自动关闭,也没啥错误提示。
新搭建的uni-app还是报sass警告,导致打包到40%窗口自动关闭,也没啥错误提示。
开发环境 | 版本号 | 项目创建方式 |
---|---|---|
Windows | win11 | HBuilderX |
产品分类:uniapp/App
PC开发环境操作系统:Windows
PC开发环境操作系统版本号:win11
HBuilderX类型:正式
HBuilderX版本号:4.57
手机系统:Android
手机系统版本号:Android 15
手机厂商:华为
手机机型:华为
页面类型:vue
vue版本:vue3
打包方式:云端
项目创建方式:HBuilderX
示例代码:
Please note that in running mode, due to log output, sourcemap, and uncompressed source code, the performance and package size are not as good as release mode.
Vite is compiled on demand, and clicking on an uncompiled page at runtime will compile first and then load, resulting in a slower display, and there is no such problem after release.
Compiler version: 4.56(vue3)
Compiling...
Re-optimizing dependencies because lockfile has changed
vite v5.2.8 dev server running at:
➜ Local: http://localhost:5173/
➜ Network: http://192.168.1.7:5173/
➜ Network: http://172.18.0.1:5173/
➜ Network: http://172.28.48.1:5173/
ready in 1060ms.
Deprecation Warning [legacy-js-api]: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0.
More info: https://sass-lang.com/d/legacy-js-api
Deprecation Warning [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
More info and automated migrator: https://sass-lang.com/d/import
╷
16 │ @import "@/uni_modules/vk-uview-ui/theme.scss";
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
src\App.vue 16:9 root stylesheet
Deprecation Warning [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
More info and automated migrator: https://sass-lang.com/d/import
╷
80 │ @import "./uni_modules/vk-uview-ui/index.scss";
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
src\App.vue 80:10 root stylesheet
Deprecation Warning [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
More info and automated migrator: https://sass-lang.com/d/import
╷
2 │ @import "./libs/css/common.scss";
│ ^^^^^^^^^^^^^^^^^^^^^^^^
╵
src\uni_modules\vk-uview-ui\index.scss 2:9 @import
src\App.vue 80:10 root stylesheet
Deprecation Warning [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
More info and automated migrator: https://sass-lang.com/d/import
╷
3 │ @import "./libs/css/color.scss";
│ ^^^^^^^^^^^^^^^^^^^^^^^
╵
src\uni_modules\vk-uview-ui\index.scss 3:9 @import
src\App.vue 80:10 root stylesheet
Deprecation Warning [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
More info and automated migrator: https://sass-lang.com/d/import
╷
7 │ @import "./libs/css/style.vue.scss";
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
src\uni_modules\vk-uview-ui\index.scss 7:9 @import
src\App.vue 80:10 root stylesheet
Warning: 1 repetitive deprecation warnings omitted.
操作步骤:
Please note that in running mode, due to log output, sourcemap, and uncompressed source code, the performance and package size are not as good as release mode.
Vite is compiled on demand, and clicking on an uncompiled page at runtime will compile first and then load, resulting in a slower display, and there is no such problem after release.
Compiler version: 4.56(vue3)
Compiling...
Re-optimizing dependencies because lockfile has changed
vite v5.2.8 dev server running at:
➜ Local: http://localhost:5173/
➜ Network: http://192.168.1.7:5173/
➜ Network: http://172.18.0.1:5173/
➜ Network: http://172.28.48.1:5173/
ready in 1060ms.
Deprecation Warning [legacy-js-api]: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0.
More info: https://sass-lang.com/d/legacy-js-api
Deprecation Warning [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
More info and automated migrator: https://sass-lang.com/d/import
╷
16 │ @import "@/uni_modules/vk-uview-ui/theme.scss";
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
src\App.vue 16:9 root stylesheet
Deprecation Warning [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
More info and automated migrator: https://sass-lang.com/d/import
╷
80 │ @import "./uni_modules/vk-uview-ui/index.scss";
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
src\App.vue 80:10 root stylesheet
Deprecation Warning [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
More info and automated migrator: https://sass-lang.com/d/import
╷
2 │ @import "./libs/css/common.scss";
│ ^^^^^^^^^^^^^^^^^^^^^^^^
╵
src\uni_modules\vk-uview-ui\index.scss 2:9 @import
src\App.vue 80:10 root stylesheet
Deprecation Warning [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
More info and automated migrator: https://sass-lang.com/d/import
╷
3 │ @import "./libs/css/color.scss";
│ ^^^^^^^^^^^^^^^^^^^^^^^
╵
src\uni_modules\vk-uview-ui\index.scss 3:9 @import
src\App.vue 80:10 root stylesheet
Deprecation Warning [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
More info and automated migrator: https://sass-lang.com/d/import
╷
7 │ @import "./libs/css/style.vue.scss";
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
src\uni_modules\vk-uview-ui\index.scss 7:9 @import
src\App.vue 80:10 root stylesheet
Warning: 1 repetitive deprecation warnings omitted.
预期结果:
Please note that in running mode, due to log output, sourcemap, and uncompressed source code, the performance and package size are not as good as release mode.
Vite is compiled on demand, and clicking on an uncompiled page at runtime will compile first and then load, resulting in a slower display, and there is no such problem after release.
Compiler version: 4.56(vue3)
Compiling...
Re-optimizing dependencies because lockfile has changed
vite v5.2.8 dev server running at:
➜ Local: http://localhost:5173/
➜ Network: http://192.168.1.7:5173/
➜ Network: http://172.18.0.1:5173/
➜ Network: http://172.28.48.1:5173/
ready in 1060ms.
Deprecation Warning [legacy-js-api]: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0.
More info: https://sass-lang.com/d/legacy-js-api
Deprecation Warning [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
More info and automated migrator: https://sass-lang.com/d/import
╷
16 │ @import "@/uni_modules/vk-uview-ui/theme.scss";
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
src\App.vue 16:9 root stylesheet
Deprecation Warning [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
More info and automated migrator: https://sass-lang.com/d/import
╷
80 │ @import "./uni_modules/vk-uview-ui/index.scss";
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
src\App.vue 80:10 root stylesheet
Deprecation Warning [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
More info and automated migrator: https://sass-lang.com/d/import
╷
2 │ @import "./libs/css/common.scss";
│ ^^^^^^^^^^^^^^^^^^^^^^^^
╵
src\uni_modules\vk-uview-ui\index.scss 2:9 @import
src\App.vue 80:10 root stylesheet
Deprecation Warning [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
More info and automated migrator: https://sass-lang.com/d/import
╷
3 │ @import "./libs/css/color.scss";
│ ^^^^^^^^^^^^^^^^^^^^^^^
╵
src\uni_modules\vk-uview-ui\index.scss 3:9 @import
src\App.vue 80:10 root stylesheet
Deprecation Warning [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
More info and automated migrator: https://sass-lang.com/d/import
╷
7 │ @import "./libs/css/style.vue.scss";
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
src\uni_modules\vk-uview-ui\index.scss 7:9 @import
src\App.vue 80:10 root stylesheet
Warning: 1 repetitive deprecation warnings omitted.
实际结果:
更多关于新搭建的uni-app还是报sass警告,导致打包到40%窗口自动关闭,也没啥错误提示。的实战教程也可以访问 https://www.itying.com/category-93-b0.html
打包前请先真机运行。
我看你选择的vue3,vue3的scss编译器就是dart-saas,需要确保自己的scss代码符合dart-saas语法。
如果你用的三方ui不支持dart-saas,需要找作者适配修改。
vue3下没有回退node-saas的选项。
更多关于新搭建的uni-app还是报sass警告,导致打包到40%窗口自动关闭,也没啥错误提示。的实战教程也可以访问 https://www.itying.com/category-93-b0.html
上周都正常的,一直都正常打包,也没sass警告,这周就更新了下依赖,就一直提示这个,把依赖还原回去,也还是提示sass警告,回不去了。
回复 b***@qq.com: 是这样的,不过升级sass和sassloader可以没有警告,但是会有其他影响,具体是是啥影响不得知,我也不敢升,警告就警告吧,只能等三方去优化了
这个问题是由于Dart Sass版本升级导致的兼容性问题。警告信息显示Sass的@import语法已被弃用,将在未来版本中移除。
解决方法:
-
升级uView UI到最新版本(建议使用3.x版本),新版本已经适配了Sass的新语法。
-
临时解决方案(不推荐长期使用): 在项目根目录的vite.config.js中添加以下配置:
css: {
preprocessorOptions: {
scss: {
additionalData: `@use "sass:math";`
}
}
}
- 如果必须使用当前版本的uView,可以尝试锁定sass版本:
npm install sass@1.32.13