Skip to content

Instantly share code, notes, and snippets.

@andreareginato
Last active August 29, 2015 14:02
Show Gist options
  • Save andreareginato/13a11cd66a705b2ae749 to your computer and use it in GitHub Desktop.
Save andreareginato/13a11cd66a705b2ae749 to your computer and use it in GitHub Desktop.
Excerpt of Grunt file needed to concat CSS and JS files
grunt.registerTask('build', [
'clean:dist',
'copy',
'useminPrepare',
'concat',
'string-replace',
]);
// Reads HTML for usemin blocks to enable smart builds that automatically
// concat, minify and revision files. Creates configurations in memory so
// additional tasks can operate on them
useminPrepare: {
html: '<%= yeoman.app %>/index.html',
options: {
dest: '<%= yeoman.dist %>',
flow: {
html: {
steps: {
js: ['concat'],
css: ['concat']
},
post: {}
}
}
}
},
// Copies remaining files to places other tasks can use
copy: {
dist: {
files: [{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.dist %>',
src: [
'views/{,*/}*.html',
]
}]
},
styles: {
}
},
// add description label of the final result
concat: {
options: {
banner: '/* <%= yeoman.name %> - v<%= yeoman.version %> - ' + '<%= grunt.template.today("yyyy-mm-dd") %> */\n\n'
}
},
// replace pieces of string
'string-replace': {
dist: {
files: {
'./': 'dist/**/*.*'
},
options: {
replacements: [{
pattern: /views\/templates\/default\.html/g,
replacement: 'bower_components/<%= yeoman.name %>/dist/views/templates/default.html'
}]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment