[英]How implement sass:math into vue.config.js
I am using vue-cli - Vue on v2.6;我在 v2.6 上使用 vue-cli - Vue; sass v1.49 - and using simple division calculations, but I follow receiving errors in the console:
sass v1.49 - 并使用简单的除法计算,但我在控制台收到错误消息:
Deprecation Warning: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.
弃用警告:在 calc() 之外使用 / 进行除法已弃用,并将在 Dart Sass 2.0.0 中删除。
I tried some documentations ( 'webpack-contrib::implementation' ; 'dev.to::how to use dart-sass with vue' ), which asks you to configure vue.config.js like this:我尝试了一些文档( 'webpack-contrib::implementation' ; 'dev.to::how to use dart-sass with vue' ),它要求你像这样配置 vue.config.js :
module.exports = {
css: {
loaderOptions: {
scss: {
implementation: require("sass"),
},
},
},
};
But without success:但没有成功:
Syntax Error: ValidationError: Invalid options object. Sass Loader has been initialized using an options object that does not match the API schema.
语法错误:ValidationError:无效选项 object。Sass 加载程序已使用与 API 架构不匹配的选项 object 进行了初始化。
- options.implementation should be an object: object { … } -> The implementation of the sass to be used ( https://github.com/webpack-contrib/sass-loader#implementation ).
options.implementation 应该是 object: object { … } -> 要使用的 sass 的实现 ( https://github.com/webpack-contrib/sass-loader#implementation )。
So how do I implement the use of sass: Math in Vue-cli?那么如何在Vue-cli中实现sass:Math的使用呢?
After some time trying some solutions, the easiest has been implemented like this:经过一段时间尝试一些解决方案后,最简单的实现如下:
module.exports = {
css: {
loaderOptions: {
scss: {
prependData: '@use "sass:math";',
},
},
},
};
As I use a global variable file, the final setup was like this:当我使用全局变量文件时,最终设置如下:
module.exports = {
css: {
loaderOptions: {
scss: {
prependData: `
@use "sass:math";
@import "~@/assets/scss/src/_variables.scss";
`,
},
},
},
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.