如何在一个Javascript文件上运行grunt?
我在我的项目中有很多javascript错误,当我在我的项目上运行grunt时,它从未完成扫描,因为错误,它以一定的百分比停止,我如何为一个文件设置grunt。任何帮助都将不胜感激 这是我为这个项目准备的文件 Grunfile.js如何在一个Javascript文件上运行grunt?,javascript,angularjs,gruntjs,yeoman,karma-jasmine,Javascript,Angularjs,Gruntjs,Yeoman,Karma Jasmine,我在我的项目中有很多javascript错误,当我在我的项目上运行grunt时,它从未完成扫描,因为错误,它以一定的百分比停止,我如何为一个文件设置grunt。任何帮助都将不胜感激 这是我为这个项目准备的文件 Grunfile.js module.exports = function(grunt) { require('load-grunt-tasks')(grunt); require('time-grunt')(grunt); grunt.initConfig({
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
require('time-grunt')(grunt);
grunt.initConfig({
// Project settings
yeoman: {
app: 'src/main/webapp',
dist: 'target/generated-source/yeoman'
},
clean: {
dist: {
files: [{
dot: true,
src: ['.tmp', '<%= yeoman.dist %>/*', '!<%= yeoman.dist %>/.svn*', 'ngdoc/generated', 'target/ngdoc']
}]
}
},
// Add vendor prefixed styles
autoprefixer: {
options: {
browsers: ['last 1 version']
},
dist: {
files: [{
expand: true,
cwd: '.tmp/styles/',
src: '**/*.css',
dest: '.tmp/styles/'
}]
}
},
// Renames files for browser caching purposes
rev: {
dist: {
files: {
src: ['<%= yeoman.dist %>/scripts/**/*.js', '<%= yeoman.dist %>/styles/**/*.css', '<%= yeoman.dist %>/images/**/*.{png,jpg,jpeg,gif,webp,svg}']
}
}
},
// Reads HTML for usemin blocks to enable smart builds that automatically
// concat, minify and revision files. Creates configurations in memory so
// additional tasks can operate on them
useminPrepare: {
html: ['<%= yeoman.app %>/*.html', '<%= yeoman.app %>/views/**/*.html'],
options: {
dest: '<%= yeoman.dist %>'
}
},
// Performs rewrites based on rev and the useminPrepare configuration
usemin: {
html: ['<%= yeoman.dist %>/**/*.html'],
css: ['<%= yeoman.dist %>/styles/**/*.css'],
js: ['<%= yeoman.dist %>/scripts/**/*.js'],
options: {
assetsDirs: ['<%= yeoman.dist %>', '<%= yeoman.dist %>/styles/**/*'],
patterns: {
js: [[/css:"assets\/styles\/?[A-Za-z]*\/+([A-Za-z0-9]+\.css)"}/g, 'revved css resolves']]
}
}
},
// Allow the use of non-minsafe AngularJS files. Automatically makes it
// minsafe compatible so Uglify does not destroy the ng references
ngAnnotate: {
dist: {
files: [{
expand: true,
cwd: '.tmp/concat/scripts',
src: '*.js',
dest: '.tmp/concat/scripts',
exclude: 'vendor.js'
}]
},
dist1: {
files: [{
expand: true,
cwd: '.tmp/concat/scripts',
src: 'controller.js',
dest: '.tmp/concat/scripts',
exclude: '!vendor.js'
}]
}
},
你可以运行一个像grunt concat这样的任务,使用concat:yourfile创建新任务,然后使用grunt concat:yourfiles这样的任务。对不起,我是grunt的新手,如何创建一个新任务?它抛出了一个错误,需要配置属性concat:processController.js丢失了一个示例作为答案,因为这里的解释太长了。