Skip to content

Instantly share code, notes, and snippets.

@Camwyn
Created May 26, 2017 15:56
Show Gist options
  • Save Camwyn/3ce755f35eb598ec7d34221b044af0ce to your computer and use it in GitHub Desktop.
Save Camwyn/3ce755f35eb598ec7d34221b044af0ce to your computer and use it in GitHub Desktop.
module.exports = {
main: ['release/<%= pkg.version %>'],
clean: ['assets/svg/min/*.svg']
};
module.exports = function (grunt) {
grunt.registerTask( 'default', ['svg', 'css', 'js'] );
};
// Main Grunt task for creating svg iconsmodule.exports = {
module.exports = function (grunt) {
grunt.registerTask( 'svg', ['clean', 'svgmin', 'svgstore'] );
};
module.exports = {
options: {
plugins: [
{
removeUselessStrokeAndFill: false
}
]
},
files: {
files: [ {
expand: true,
cwd: 'assets/svg/src',
src: ['**/*.svg'],
dest: 'assets/svg/min'
} ]
}
};
module.exports = {
main: {
files: {
'assets/svg/symbol-defs.svg': ['assets/svg/min/*.svg']
},
options: {
cleanup: true,
inheritviewbox: true,
prefix : 'icon-',
formatting : {
indent_with_tabs: true
},
svg: {
style: "position: absolute; width: 0; height: 0; overflow: hidden;",
version: "1.1",
xmlns: "http://www.w3.org/2000/svg",
},
symbol: {
preserveAspectRatio: 'none slice' // helps with some IE bugs
}
}
}
};
module.exports = {
livereload: {
files: ['assets/css/*.css', 'assets/js/src/**/*.js'],
options: {
livereload: true
}
},
svg: {
files: ['assets/svg/src/**/*svg'],
tasks: ['svg', 'css'],
options: {
debounceDelay: 500
}
},
css: {
files: ['assets/css/sass/**/*.scss'],
tasks: ['svg', 'css'],
options: {
debounceDelay: 500
}
},
js: {
files: ['assets/js/src/**/*.js', 'assets/js/vendor/**/*.js'],
tasks: ['js'],
options: {
debounceDelay: 500
}
},
};
@Camwyn
Copy link
Author

Camwyn commented May 26, 2017

Grunt (w/grunt-tasks) for building svg icons

@Camwyn
Copy link
Author

Camwyn commented May 26, 2017

A few notes:

clean.js is essential for preventing any file corruption - not sure why it happens, but sometimes it does (or just fails) without it.

The order is important - clean then svgmin, then svgstore.

For proper creation of the data urls, it's important to run both svg and css for any change in either folder in your watch tasks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment