gpt4 book ai didi

angular - karma .config : sass tilde importer

转载 作者:太空狗 更新时间:2023-10-29 17:58:18 28 4
gpt4 key购买 nike

我通过 angular-cli 设置了一个 angular 6 项目。

我安装了 karma-scss-preprocessor 作为开发依赖,以便在 karma 测试中加载 sass 文件。以下 karma.config:

...
config.set({
basePath: '',
browserNoActivityTimeout: 60000,
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-phantomjs-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma'),
require('karma-scss-preprocessor')
],
preprocessors: {
'styles.scss': ['scss'],
},
files: [
{ pattern: 'styles.scss', watched: true, included: true, served: true }
],
...

现在我得到错误:

File to import not found or unreadable: ~@onepackage/onelib/scss/all.

由于在 styles.scss 中导入 onepackage/lib 时出现波浪号。

我尝试在 karma.json 的插件部分添加 require('node-sass-tilde-importer'),但没有解决。

有什么建议吗?

最佳答案

你必须在 karma-scss-preprocessor 选项中调用 require('node-sass-tilde-importer')

...
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-phantomjs-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma'),
require('karma-scss-preprocessor')
],
scssPreprocessor: {
options: {
importer: require('node-sass-tilde-importer')
}
},
...

关于angular - karma .config : sass tilde importer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52382190/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com