【发布时间】:2014-04-16 21:36:09
【问题描述】:
我已使用 grunt-contrib-sass 插件将 Sass 任务添加到我的 grunt 进程中。这是我的 gruntfile:
module.exports = function ( grunt ) {
grunt.loadNpmTasks('grunt-contrib-sass');
/**
* Load in our build configuration file.
*/
var userConfig = require( './build.config.js' );
/**
* This is the configuration object Grunt uses to give each plugin its
* instructions.
*/
var taskConfig = {
/**
* We read in our `package.json` file so we can access the package name and
* version. It's already there, so we don't repeat ourselves here.
*/
pkg: grunt.file.readJSON("package.json"),
sass: {
dev: {
files: [{
expand: true,
cwd: 'css',
src: ['**/*.scss'],
dest: 'css',
ext: '.css'
}]
},
prod: {
files: [{
expand: false,
cwd: 'css',
src: ['**/*.scss'],
dest: 'css',
ext: '.css'
}]
}
},
};
grunt.initConfig( grunt.util._.extend( taskConfig, userConfig ) );
grunt.registerTask('default', [ 'sass:prod' ]);
grunt.registerTask('dev-build', [ 'sass']);
grunt.registerTask('sass', [ 'sass:dev' ]);
grunt.event.on('watch', function(action, filepath, target) {
grunt.log.writeln(target + ': ' + filepath + ' has ' + action);
});
};
我已经安装了 Ruby 1.9.3 和 Sass Gem 3.3.2,并通过命令行和 IntelliJ 13 运行。但是当我尝试运行 grunt sass 或将 grunt watch 应用到我的 scss 时文件,我得到以下跟踪输出:
<c:\users\[proj_dir_path]>grunt sass --verbose
Initializing
Command-line options: --verbose
Reading "gruntfile.js" Gruntfile...OK
Registering Gruntfile tasks.
Registering "grunt-contrib-sass" local Npm module tasks.
Reading C:\Users\[proj_path]\node_modules\grunt-contrib-sass\package.json...OK
Parsing C:\Users\[proj_path]\node_modules\grunt-contrib-sass\package.json...OK
Loading "sass.js" tasks...OK
+ sass
Reading package.json...OK
Parsing package.json...OK
Initializing config...OK
Loading "gruntfile.js" tasks...OK
+ sass
Running tasks: sass
Running "sass" task
[About 500 more repeats of this]
Running "sass" task
Warning: Maximum call stack size exceeded Use --force to continue.
Aborted due to warnings.
要运行 SCSS Gem,我必须执行带有参数的 scss.bat 命令。我最好的猜测是 Grunt Sass 插件正在尝试使用参数执行 Ruby EXE,而在我的系统上我必须使用 bat 运行它。这只是我梳理 sass.js 任务代码的猜测。有没有其他人遇到过类似的问题,是否有任何解决方法或解决方案?
【问题讨论】:
标签: javascript ruby node.js sass gruntjs