问题
My grunt file is shown below:
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
src: 'src/**/*.js',
dest: 'dist/<%= pkg.name %>.min.js'
}
},
watch: {
js: {
files: ['src/**/*.js'],
options: {
livereload: '<%= connect.options.livereload %>'
}
},
livereload: {
options: {
livereload: '<%= connect.options.livereload %>'
},
files: [
'src/**/*.html',
'src/**/*.css',
'src/assets/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
]
}
},
connect: {
options: {
port: 9000,
livereload: 35729,
hostname: 'localhost'
},
livereload: {
options: {
open: true,
// base: [
// '.tmp',
// ''
// ]
middleware: function(connect) {
return [
connect.static('.tmp'),
connect().use(
'/bower_components',
connect.static('./bower_components')
),
connect().use(
'/app/styles',
connect.static('./app/styles')
),
connect.static('src')
];
}
}
}
},
copy: {
app: {
cwd: 'src', // set working folder / root to copy
src: '**/*.html', // copy all files and subfolders
dest: 'dist/', // destination folder
expand: true
},
assets: {
cwd: 'src', // set working folder / root to copy
src: 'assets/*', // copy all files and subfolders
dest: 'dist/', // destination folder
expand: true
}
},
useminPrepare: {
options: {
dest: 'dist'
},
html: 'src/index.html'
},
usemin: {
html: ['dist/index.html']
}
});
// Load the plugin that provides the "uglify" task.
// grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-usemin');
// Default task(s).
grunt.registerTask('default', ['useminPrepare', 'copy', 'concat', 'uglify', 'usemin']);
grunt.registerTask('serve', function(target) {
grunt.task.run([
'connect:livereload',
'watch'
]);
});
};
when i run grunt getting error message as "No "concat" targets found". I have been trying for 2 hours to solve this problem but no result pls help me to get the solution.
回答1:
Way too late, but just in case it is useful for somebody else: I believe useminprepare will auto-generate a concat configuration and feed it to the grunt task runner, so above responses are not quite accurate I would say.
I would try reviewing the build blocks in src/index.html and check that the paths point properly to the resources that useminPrepare will concatenate. I'm struggling now with a problem like this :S
Reference here: https://github.com/yeoman/grunt-usemin
回答2:
Use the following process to debug:
Run the sample project
Specify a
temp
storage location (temp
orstaging
) directoryBefore running
usemin
, make sure thetemp
orstaging
directory is not emptyIf it is empty, run a
grunt copy
task which has thetemp
orstaging
directory set as thedest
parameter
The main difference to be kept in mind, regarding directories and tasks, is that for
useminPrepare
, the directories needs to indicate the input, transient and output path needed to output the right configuration for the processors pipeline, whereas in the case ofusemin
it only reflects the output paths, as all the needed assets should have been output to the destination dir (either transformed or just copied).
References
grunt-usemin github repo: README
Concat, Uglify and Usemin Prepare
来源:https://stackoverflow.com/questions/31409150/getting-error-message-no-concat-targets-found-when-running-grunt-usemin