我尝试使用GruntJS来完成一个简单的任务来美化一些js / css,使用grunt-beautify插件。这是最基本的任务,我不能没有错误地运行美化。 uglify任务运行正常,我只是没有看到美化任务的问题。
/*global module:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
// Task configuration.
beautify: {
files: {
src: '../myProject/css*/*.css',
dest: './'
}
},
uglify: {
files: {
src: 'dev/*.css'
}
},
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-beautify');
// Default task.
//grunt.registerTask('default', ['beautify']);
};
Registering "grunt-beautify" local Npm module tasks.
Reading /path/to/grunt/node_modules/grunt-beautify/package.json...OK
Parsing /path/to/grunt/node_modules/grunt-beautify/package.json...OK
Loading "beautify.js" tasks...OK
+ beautify
Loading "Gruntfile.js" tasks...OK
>> No tasks were registered or unregistered.
Running tasks: beautify
Running "beautify" task
[D] Task source: /path/to/grunt/node_modules/grunt-beautify/tasks/beautify.js
Running "beautify:files" (beautify) task
[D] Task source: /path/to/grunt/node_modules/grunt-beautify/tasks/beautify.js
Verifying property beautify.files exists in config...OK
Files: ../myProject/css_3.3.6/bootstrap.min.css, ../myProject/css_3.3.6/fonts.css, ../myProject/css_3.3.6/styles.css -> ./
Using beautifier default options.
Warning: Cannot read property 'src' of undefined Use --force to continue.
TypeError: Cannot read property 'src' of undefined
at Object.<anonymous> (/path/to/grunt/node_modules/grunt-beautify/tasks/beautify.js:52:37)
at Object.<anonymous> (/path/to/grunt/node_modules/grunt/lib/grunt/task.js:264:15)
at Object.thisTask.fn (/path/to/grunt/node_modules/grunt/lib/grunt/task.js:82:16)
at Object.<anonymous> (/path/to/grunt/node_modules/grunt/lib/util/task.js:296:30)
at Task.runTaskFn (/path/to/grunt/node_modules/grunt/lib/util/task.js:246:24)
at Task.<anonymous> (/path/to/grunt/node_modules/grunt/lib/util/task.js:295:12)
at /path/to/grunt/node_modules/grunt/lib/util/task.js:222:11
at process._tickCallback (node.js:419:13)
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
Aborted due to warnings.
答案 0 :(得分:0)
无法提醒
beautify: {
files: {
src: '../myProject/css*/*.css',
dest: './'
}
}
但是grunt-beautify假设在.js文件上运行而不是在.css文件上运行。项目grunt file中的任何内容都没有暗示。