Reputation: 3116
I am trying to use grunt-usemin
to concatenate, minify, and remove unused optimized references from my project. I have set up the build
blocks in my index.html
file as so:
Index.html
<!-- build:js js/optimized.js-->
<script src="app/app.js"></script>
<script src="app/config.js"></script>
<script src="app/config.exceptionHandler.js"></script>
<script src="app/config.route.js"></script>
<script src="app/common/common.js"></script>
<script src="app/common/bootstrap/bootstrap.dialog.js"></script>
<script src="app/controller1/controller1.js"></script>
<script src="app/services/service.js"></script>
<!-- endbuild -->
and my gruntfile.js
looks like:
"use strict";
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
useminPrepare: {
html: 'index.html',
options: {
dest: '/dist'
}
},
usemin: {
options: {
dirs: ['dist/index.html']
}
}
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-usemin');
grunt.registerTask('testtask', ['useminPrepare', 'concat', 'uglify', 'usemin']);
};
However, usemin
never actually generates the concat
or uglify
methods in my gruntfile.js
. Instead, when trying to run
grunt.registerTask('newtask', ['useminPrepare', 'concat', 'uglify', 'usemin']);
I get an error stating that "No "concat" targets found".
My gruntfile.js
and index.html
are both in the root directory. Is there something I am doing wrong here?
EDIT: Running with --verbose
Running tasks: useminPrepare
Running "useminPrepare" task
Running "useminPrepare:html" (useminPrepare) task
Verifying property useminPrepare.html exists in config...OK
Files: [no src] -> html
Options: dest="/dist"
Going through to update the config
Looking for build script HTML comment blocks
Configuration is now:
concat:
undefined
uglify:
undefined
cssmin:
undefined
Upvotes: 1
Views: 2547
Reputation: 649
Like spamguy say: This error occur is because you write your html file path wrong.
as common it's:
useminPrepare: {
html: ['<%= yeoman.app %>/index.html'],
options: {
dest: '<%= yeoman.dist %>'
}
}
please make sure usemin can find your index.html file by your html config.
Upvotes: 1
Reputation: 1566
Your index.html reference inside useminPrepare is missing client/
:
useminPrepare: {
html: 'client/index.html',
options: {
dest: '/dist'
}
}
I compared against a project I'm working on that appears to have used the same yeoman generator.
Upvotes: 0