Matt McDonald
Matt McDonald

Reputation: 5050

How to include third party library with Grunt

New to Grunt, and have been using it for the first time to combine/minify JS files for a project.

Currently have this (relevant section) in Gruntfile.js:

concat: { options: { banner: '<%= banner %>', stripBanners: true }, dist: { src: [ 'build/js/sample_file', 'build/js/another_file.js' ], dest: 'dist/<%= pkg.build_name %>-<%= pkg.version %>.js' } }, uglify: { options: { banner: '<%= banner %>' }, dist: { src: '<%= concat.dist.dest %>', dest: 'dist/<%= pkg.build_name %>-<%= pkg.version %>.min.js' } },

That's working fine, but I'm not sure how to do the next thing I need. My project requires Hammer.js.

I could just include the library in the concat, but this doesn't seem right to me for 2 reasons. It's already minified (I could get un-minified, but seems a bit of a waste of time when minified already), and it would seem Grunt would be a bit cleverer than this, and could be used to download the latest Hammer library for me?

How do I get Grunt to include a third-party JS library in the uglified code it builds?

Upvotes: 0

Views: 831

Answers (1)

hereandnow78
hereandnow78

Reputation: 14434

use bower for your dependency-management of vendor libraries

use grunt for linting, testing, building

it's not possible to tell you on how to combine these two, as your question is to unspecific.

in general i would use yeoman and some generator to get my project setup. if none of them satisfies your needs, try to learn from them!

Upvotes: 1

Related Questions