Grunt Sass Error: File to import not found or unreadable
Grunt Sass Error: File to import not found or unreadable
这在本地有效,但是当我在我的 ubuntu 上 g运行t 时,我得到这个 sass 错误。我安装了 ruby 和 sass,还有 g运行t
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.
如错误所示,我使用 g运行t 来 运行 我的东西。这是我 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";
这是我的 g运行t 文件
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 import 路径。根据 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'
}
}
}
});
这在本地有效,但是当我在我的 ubuntu 上 g运行t 时,我得到这个 sass 错误。我安装了 ruby 和 sass,还有 g运行t
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.
如错误所示,我使用 g运行t 来 运行 我的东西。这是我 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";
这是我的 g运行t 文件
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 import 路径。根据 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'
}
}
}
});