我有 D:/projectA
Gruntfile.js
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
//Read the package.json (optional)
pkg: grunt.file.readJSON('package.json'),
// Metadata.
meta: {
basePath: '../',
srcPath: '../',
deployPath: '../'
},
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> ',
// Task configuration.
concat: {
options: {
stripBanners: true
},
dist: {
src: ['<%= meta.srcPath %>engine/css/mycss1.css', '<%= meta.srcPath %>engine/css/mycss2.css'],
dest: '<%= meta.deployPath %>engine/css/00myfinal.css'
}
},
//the Sass Task
sass: {
sass_my_files : {
files : {
//"the Destination " : " the source files"
"../engine/css/mystyle3.css" : "../engine/css/mysass1.scss",
},
options : {
"style":"compressed",
"precision":"7"
},
},
},
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-sass');
// Default task
grunt.registerTask('default', ['concat','sass']);
};
package.json
{
"name": "Test-Project",
"version": "0.1.0",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-concat": "~0.1.3"
}
}
Ruby 安装在我的“Windows”上。
插入以下命令:
npm install ruby-sass
我把一切都搞定了。但是在运行“Grunt”命令时,我收到错误:
You need to have Ruby and Sass installed and in your path for this task to work.
有人可以告诉我为什么我的控制台在成功运行“concat”任务后显示错误,并在“SASS<”上显示错误/em>'任务?
最佳答案
使用npm install -g ruby-sass
,它会在环境变量中全局安装 ruby-sass gem。然后继续。
我建议使用 Gulp 而不是 Grunt。它们的功能相似,但我更喜欢 Gulp,因为它的管道 Assets 。确实值得学习。
关于javascript - Node.js 通过 Grunt 运行 SASS 预处理器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33128133/