Skip to content

Instantly share code, notes, and snippets.

@rrharvey
Created November 27, 2013 15:57
Show Gist options
  • Save rrharvey/7678052 to your computer and use it in GitHub Desktop.
Save rrharvey/7678052 to your computer and use it in GitHub Desktop.
This example shows how to add script elements automatically that will be processed using grunt-usemin. This example uses the html and Gruntfile.js from the AngularJS generator for Yeoman. The default for mode for grunt-file-blocks is to add newly discovered files only. Once a script element has been added you can move the lines around inside the…
<!-- ... content removed -->
<!-- build:js({.tmp,app}) scripts/scripts.js -->
<!-- fileblock:js scripts -->
<script src="scripts/app.js"></script>
<script src="scripts/controllers/main.js"></script>
<!-- endfileblock -->
<!-- endbuild -->
</body>
</html>
// ... content removed
// Performs rewrites based on rev and the useminPrepare configuration
usemin: {
html: ['<%= yeoman.dist %>/{,*/}*.html'],
css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
options: {
assetsDirs: ['<%= yeoman.dist %>']
}
},
// Adds script elements to the HTML file
fileblocks: {
html: {
src: 'app/index.html',
blocks: {
'scripts': {
src: [
'scripts/app.js',
'scripts/services/*.js',
'scripts/controllers/*.js'
],
cwd: 'app'
}
}
}
},
// ... content removed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment