我使用grunt-contrib-sass插件将Sass任务添加到我的grunt进程中。这是我的文件:
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);
});
};我安装了Ruby1.9.3和Sass Gem 3.3.2,并从命令行和IntelliJ 13中运行。但是,当我尝试运行grunt sass或对我的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,我必须使用参数执行scss.bat命令。我最好的猜测是,Grunt插件试图使用参数来执行Ruby,而在我的系统中,我必须用蝙蝠来运行它。这只是我在梳理sass.js任务代码时的猜测。有没有其他人有类似的问题,有没有任何解决办法或解决这一点?
发布于 2014-04-03 10:05:43
我认为这是一个递归问题,注册的任务正在循环中运行。
我的工作没有
grunt.registerTask('sass','sass:dev‘);
正如它所显示的那样,initConfig中设置的任何内容都自动是一个任务。如果删除该行不起作用,请重命名它
Grunt.registerTask(‘my’,'sass:dev‘);
和奔跑
咕哝着我的小屁屁
发布于 2014-03-12 15:54:57
试着换衣服-
grunt.registerTask('sass', [ 'sass' ]);至
grunt.registerTask('sass', [ 'sass:dev' ]);或
grunt.registerTask('sass', [ 'sass:prod' ]);https://stackoverflow.com/questions/22356816
复制相似问题