這是我第一次嘗試配置一個Gruntfile.js,我似乎無法弄清楚是什麼導致這個「警告:任務」默認「沒有找到,使用--force繼續。由於警告。「錯誤。有人可以幫我弄清楚我的代碼有什麼問題。查找源代碼如下:Gruntfile.js語法錯誤:警告:找不到任務「默認」。使用--force繼續
'use strict';
module.exports = function (grunt) {
// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);
// Automatically load required Grunt tasks
require('jit-grunt')(grunt);
// Define the configuration for all the tasks
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Make sure code styles are up to par and there are no obvious mistakes
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
all: {
src: [
'Gruntfile.js',
'app/scripts/{,*/}*.js'
]
}
}
}),
copy: {
dist: {
cwd: 'app',
src: [ '**','!styles/**/*.css','!scripts/**/*.js' ],
dest: 'dist',
expand: true
},
fonts: {
files: [
{
//for bootstrap fonts
expand: true,
dot: true,
cwd: 'bower_components/bootstrap/dist',
src: ['fonts/*.*'],
dest: 'dist'
}, {
//for font-awesome
expand: true,
dot: true,
cwd: 'bower_components/font-awesome',
src: ['fonts/*.*'],
dest: 'dist'
}
]
}
},
clean: {
build: {
src: [ 'dist/']
}
});
grunt.registerTask('build', [
'clean',
'jshint',
'copy'
]);
grunt.registerTask('build', [
'jshint'
]);
grunt.registerTask('default',['build']);
};
感謝您的幫助傑森,但我有一個名爲「默認」的任務的定義類似於您的代碼的最底部,但我仍然收到警告,就像默認任務根本不存在一樣。還有什麼建議? –