Reputation: 4840
I'm currently using the usemin task to do my concat and uglify tasks. However, I'm not getting any output from the concat/uglify tasks. Not seeing any errors or warnings. How can I get the resulting output dist/app/myscript.js script?
Gruntfile.js is as follows:
module.exports = function(grunt){
var paths = {
app: 'app',
dist: 'dist'
};
grunt.initConfig({
paths: paths,
clean: {
dist: {
src: ['<%= paths.dist %>']
}
},
copy: {
dist: {
files: [
{expand: true, cwd: '.', src: ['**'], dest: '<%= paths.dist %>/'}
]
}
},
useminPrepare: {
html: '<%= paths.dist %>/<%= paths.app %>/index.html'
},
usemin: {
html: '<%= paths.dist %>/<%= paths.app %>/index.html'
}
});
grunt.loadNpmTasks('grunt-usemin');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.registerTask('default', ['clean','copy']);
grunt.registerTask('use', ['useminPrepare','usemin'])
}
HTML Build snippet:
<!-- build:js myscript.js -->
<script type="text/javascript" src='router.js'></script>
<script type="text/javascript" src='bootstrap.js'></script>
<!-- endbuild -->
Console output:
Running "useminPrepare:html" (useminPrepare) task
Going through dist/app/index.html to update the config
Looking for build script HTML comment blocks
Found a block:
<!-- build:js myscript.js -->
<!-- Globals -->
<script type="text/javascript" src='router.js'></script>
<script type="text/javascript" src='bootstrap.js'></script>
<!-- endbuild -->
Updating config with the following assets:
- dist/app/router.js
- dist/app/bootstrap.js
Configuration is now:
cssmin:
{}
concat:
{ 'dist/app/myscript.js':
[ 'dist/app/router.js',
'dist/app/bootstrap.js' ] }
uglify:
{ 'dist/app/myscript.js': 'dist/app/myscript.js' }
requirejs:
{}
Running "usemin:html" (usemin) task
Processing as HTML - dist/app/index.html
Update the HTML to reference our concat/min/revved script files
Update the HTML with the new css filenames
Update the HTML with the new img filenames
Update the HTML with data-main tags
Update the HTML with the data tags
Update the HTML with background imgs, case there is some inline style
Update the HTML with anchors images
Update the HTML with reference in input
Done, without errors.
Upvotes: 4
Views: 4623
Reputation: 4840
It turns out the problem is with the registerTask(). You need to explicitly add concat/uglify. So it should look like this: grunt.registerTask('use', ['useminPrepare','usemin','concat','uglify'])
Upvotes: 6
Reputation: 7581
Technically grunt-usemin
isn't matured enough to give you the error incase if it fails, that's been my observations till now.
It always shows Processing as HTML, Update the HTML .......
even if it's failing somewhere.
Let's coming back to the solution, I think you have issue in your HTML Build snippet, you haven't mentioned the the correct path which should have app before myscript.js - <!-- build:js app/myscript.js -->
Let me know if it's still not solved the issue.
Upvotes: 2