Getting "No" concat "targets found" error when running grunt-usemin
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 ran the grunt message getting the error "No concat" target found ". I tried for 2 hours to get this issue resolved but no results can help me get a solution.
source to share
It's too late, but just in case it's useful for someone else: I believe that useminprepare will automatically generate a concatenated configuration and feed it to the runter tasks, so the above answers are not entirely accurate, I would say.
I would try to look at the build blocks in the src / index.html file and check if the paths point correctly to the resources that useminPrepare will be concatenating. I am currently struggling with a problem like this: S
Link here: https://github.com/yeoman/grunt-usemin
source to share
Use the following process to debug:
-
Run the sample project
-
Specify storage directory
temp
(temp
orstaging
) -
usemin
Make sure the directory istemp
or isstaging
not empty before starting . -
If it is empty, run a task
grunt copy
that has a directorytemp
orstaging
set as a parameterdest
The main difference to keep in mind regarding directories and tasks is that
useminPrepare
directories must specify the input, temporary, and output path needed to output the correct configuration for the processor pipeline, whereas in caseusemin
it only reflects the output paths, since everything the required assets had to be output to the target directory (converted or simply copied).
Links
source to share