我正在为我手头的一个小项目创建以下grunt文件。但是,它会通过以下消息中止
Running "sass:dev" (sass) task
Warning: Arguments to path.join must be strings Use --force to continue.
我在哪里做错了?有人可以向我解释一下吗?
/*!
* XXX
* @author XXXXXX
*/
'use strict';
/**
* Grunt Module
*/
module.exports = function(grunt) {
// Grunt goodness goes here
/**
* Configuration
*/
grunt.initConfig({
/**
* Get package meta data
*/
pkg: grunt.file.readJSON('package.json'),
/**
* Set project object
*/
project: {
app: 'app',
assets: '<%= project.app %>/assets',
src: '<%= project.assets %>/src',
css: [
'<%= project.src %>/styles/*.scss'
],
js: [
'<%= project.src %>/scripts/*.js'
],
dist: '<%= project.assets %>/dist',
distcss: [
'<%= project.dist %>/styles/*.scss'
],
distjs: [
'<%= project.dist %>/scripts/*.js'
],
},
/**
* Project banner
*/
tag: {
banner: '/*!\n' +
' * <%= pkg.name %>\n' +
' * <%= pkg.title %>\n' +
' * <%= pkg.url %>\n' +
' * @author <%= pkg.author %>\n' +
' * @version <%= pkg.version %>\n' +
' * Copyright <%= pkg.copyright %>. <%= pkg.license %> licensed.\n' +
' */\n'
},
/**
* Sass
*/
sass: {
dev: {
options: {
style: 'expanded',
banner: '<%= tag.banner %>',
compass: true
},
files: {
'<%= project.css %>': '<%= project.distcss %>'
}
},
dist: {
options: {
style: 'compressed',
compass: true
},
files: {
'<%= project.css %>': '<%= project.distcss %>'
}
}
},
/**
* Watch
*/
watch: {
sass: {
files: '<%= project.src %>/styles/{,*/}*.{scss,sass}',
tasks: 'sass:dev'
}
},
// Uglify
uglify: {
options: {
banner: '/*! <%= pkg.name %> Version: <%= pkg.version %> Created on: <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
src: 'src/scripts/*.js',
dest: 'build/<%= pkg.name %>.min.js'
}
}
});
/**
* Load Grunt plugins
*/
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
/**
* Default task
* Run `grunt` on the command line
*/
grunt.registerTask('default', [
'sass:dev',
'watch'
]);
};
答案 0 :(得分:1)
使用files
语法为sass任务指定something.css : something.scss
时,不能使用星号来包含多个文件。您必须单独指定每个文件,如下所示:
files: {
'one.css': 'one.scss',
'two.css': 'two.scss',
'three.css': 'three.scss',
}
或者,更好的是,使用expand
属性对目录中的所有文件执行此操作,如下所示:
files: [{
expand: true,
cwd: '<%= project.src %>/styles',
src: ['*.scss'],
dest: '<%= project.src %>/styles',
ext: '.css'
}]
grunt-contrib-sass readme中的更多内容。