gpt4 book ai didi

javascript - Grunt Sass 错误 : File to import not found or unreadable

转载 作者:行者123 更新时间:2023-11-30 00:28:47 25 4
gpt4 key购买 nike

这在本地有效,但是当我在我的 ubuntu 上发出咕噜声时,我得到了这个 sass 错误。我安装了 ruby​​ 和 sass,还有 grunt

Running "sass:dist" (sass) task
Error: File to import not found or unreadable: /public/libs/bootswatch-scss/cyborg/variables.
Load path: /opt/app/soundapp/public/style/sass
on line 1 of public/style/sass/style.scss
Use --trace for backtrace.
File "public/builds/style.css" created.

如错误所示,我使用 grunt 来运行我的东西。这是我的 style.scss 的顶部

@import "public/libs/bootswatch-scss/cyborg/variables";
@import "public/libs/bootstrap-sass-official/assets/stylesheets/bootstrap/variables";
@import "public/libs/bootstrap-sass-official/assets/stylesheets/bootstrap";
@import "public/libs/bootswatch-scss/cyborg/bootswatch";

这是我的 grunt 文件

module.exports = function(grunt){
jsFiles = [
'public/libs/underscore/underscore.js',
'public/libs/jquery/dist/jquery.js',
'public/libs/jquery-ui/jquery-ui.js',
'public/libs/jquery-ui/ui/core.js',
'public/libs/jquery-ui/ui/widget.js',
'public/libs/angular/angular.js',
'public/libs/angular-animate/angular-animate.js',
'public/libs/angular-sanitize/angular-sanitize.js',
'public/libs/angular-bootstrap/ui-bootstrap-tpls.js',
'public/libs/angular-ui-router/release/angular-ui-router.js',
'public/libs/restangular/dist/restangular.js',

'public/js/services/**/*.js',
'public/js/filters/**/*.js',
'public/js/directives/**/*.js'
],
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
dist: {
options: {
loadPath: [
'public/libs/bootstrap-sass-official/assets/stylesheets/',
'public/libs/bootstrap-sass-official/assets/stylesheets/bootstrap/',
'public/libs/font-awesome/scss',
'public/libs/bootswatch-scss/cyborg/'
],
style: 'compressed'
},
files: {
'public/builds/style.css': 'public/style/sass/style.scss'
}
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
src: 'builds/script.js',
dest: 'builds/script.min.js'
}
},
watch: {
css: {
files: '**/*.scss',
tasks: ['sass']
}
},
concat: {
options: {
separator: ';',
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
dist: {
src: jsFiles,
dest: 'public/builds/script.js'
}
},
jshint: {
all: ['public/js/**/*.js']
},
notify_hooks: {
options: {
enabled: true,
max_jshint_notifications: 5
}
},
notify: {
complete: {
options: {
message: 'Grunt Completed!'
}
},
}
});
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-notify');
grunt.registerTask('default',['jshint', 'sass', 'concat', 'notify:complete']);
}

我如何开始调试它?我的 public/libs/中的所有文件都存在,所以它必须是一个与查找文件无关的编译问题?我安装了 Sass 3.4.13 和 ruby​​ 1.9.3p484

最佳答案

此语法似乎来自旧版本,可能仍不受支持或不兼容,

sass: {
dist: {
options: {
loadPath: [ ],
style: 'compressed'
},
files: { }
}
},

但是对于 grunt-contrib-sass v0.9.2

如果您要将所有 sass 文件导入到一个主 SASS 文件中。您不必在 grunt 文件中定义所有 SASS 导入 路径。根据documentation您可以通过提供 .scss 文件和 .css 文件的路径进行编译,并在主 SASS 文件中定义导入路径。

例如:

在你的 style.scss 中假设你的目录结构是

|--- style.scss
|--- public
|--- libs
|--- bootswatch-scss

...ect

你的 style.scss 文件中会有这样的东西

@import "public/libs/bootswatch-scss/cyborg/variables";
@import "public/libs/bootswatch-scss/cyborg/bootswatch";

和你的 grunt 文件一样

grunt.initConfig({
sass: {
dist: {
files: {
'public/builds/style.css': 'public/style/sass/style.scss'
}
}
}
});

关于javascript - Grunt Sass 错误 : File to import not found or unreadable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30382124/

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