gpt4 book ai didi

javascript - NPM 无法转换 SASS

转载 作者:搜寻专家 更新时间:2023-10-31 23:12:13 24 4
gpt4 key购买 nike

我正在尝试转换我的 style.scss(它有一些其他文件链接到它,例如 _variable.scss_mixins.scss) 通过 grunt.jsnpm 文件到 css。但是我得到了这个错误:

Error: File to import not found or unreadable: compass.
on line 5 of sass/style.scss

1: // typorgraphy
2: @import "base/typography";
3:
4: // compass
5: @import "compass";
6:
7: // import files
8: @import "base/import";
9:
10: // mixins

这是我的 gruntfile.js:

module.exports = function(grunt) {

// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

compass: {
dist: {
options: {
sassDir: 'sass',
cssDir: 'css',
environment: 'production'
}
},
dev: {
options: {
sassDir: 'sass',
cssDir: 'css'
}
}
},

watch: {
sass:{
files: ['sass/*.scss'],
tasks: ['sass', 'cssmin']
}
},

sass: {
dist: {
files: {
'css/style.css' : 'sass/style.scss'
}
}
},

concat: {
options: {
separator: ';',
stripBanners: true,
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},

dist: {
src: ['js/*.js'],
dest: 'js/main.min.js'
}
},


uglify:{
options: {
manage: false,
preserveComments: 'all' //preserve all comments on JS files
},
my_target:{
files: {
'js/main.min.js' : ['js/*.js']
}
}
},


cssmin:{
my_target:{
files: [{
expand: true,
cwd: 'css/',
src: ['*.css', '!*.min.css'],
dest: 'css/',
ext: '.min.css'

}]
}
}

});

// Load the plugin that provides the "compass" task.
grunt.loadNpmTasks('grunt-contrib-compass');

// Load the plugin that provides the "watch" task.
grunt.loadNpmTasks('grunt-contrib-watch');

// Load the plugin that provides the "sass" task.
grunt.loadNpmTasks('grunt-contrib-sass');

// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-uglify');

// Load the plugin that provides the "concat" task.
grunt.loadNpmTasks('grunt-contrib-concat');

// Load the plugin that provides the "cssmin" task.
grunt.loadNpmTasks('grunt-contrib-cssmin');

// Default task(s).
grunt.registerTask('default', ['uglify','cssmin']);
};

当我运行 grunt sass 时,它给了我这些错误。 Compass 已经安装,我输入“grunt compass”以确保它正在运行。

有什么想法吗?

最佳答案

使用 grunt-contrib-sass 而不是 grunt-sass

This task requires you to have Ruby and Sass installed. If you're on OS X or Linux you probably already have Ruby installed; test with ruby
-v
in your terminal. When you've confirmed you have Ruby installed, run gem install sass to install Sass.

同时确保 compass 选项为 true。默认情况下,它设置为 false

阅读此以获取更多信息:compass option

这是一个例子:

sass: {
dist: {
options: {
compass: true,
},
files: {
'css/style.css' : 'sass/style.scss'
}
}
},
  • grunt-sass使用 libsass,它是 C++ 中的 Sass 编译器,不支持 compass 。

This task uses libsass which is a Sass compiler in C++. In contrast to the original Ruby compiler, this one is much faster, but is missing some features, though improving quickly. It also doesn't support Compass. Check out grunt-contrib-sass if you prefer something more stable, but slower.

关于javascript - NPM 无法转换 SASS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33872303/

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