Reputation: 3791
I'm looking into using Bower with my project (more specifically, django-bower), and I was curious if bower has the ability to combine multiple javascript files into one file when pushing to production.
In other words it would take:
and produce one file that the user loads: everything.js
In reality we have upwards of 20-30 js files, which is why this would be incredibly helpful.
Upvotes: 3
Views: 2720
Reputation: 2771
Use Browserify. It takes your Node requires and compiles them into a single JS file that can be included in your HTML. Ex main.js:
var JQuery = require('jquery');
var Angular = require('Angular');
require('./something_else');
require('./another_thing');
Browserify your dependency chain...
browserify main.js > compiled.js
Include in your HTML
<html>
<head>
<script type="text/javascript" src="compiled.js"></script>
</head>
</html>
Upvotes: 2
Reputation: 12579
Bower
is a package manager. I think what you're looking for is Grunt.
See how to minify multiple js files using grunt
.
Upvotes: 4