Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bundling module for NODE.JS

ASP.NET MVC 4 has brought amazing tool for bundling multiple stylesheets or javascripts into one like this:

bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
                    "~/Content/themes/base/jquery.ui.core.css",
                    "~/Content/themes/base/jquery.ui.datepicker.css",
                    "~/Content/themes/base/jquery.ui.theme.css"));

Does NODE.JS have any modules to fulfil the same task - to bundle client javascript libraries into one? I've seen tools like browserify, uglifier, etc. but these require manual invocation of console commands (or may I have missed something?). Meanwhile, it would be nice to eliminate that excessive step and have middleware that could be easily integrated into express.js application, for instance.

like image 459
koss Avatar asked Dec 25 '12 04:12

koss


People also ask

Are node modules bundled?

And that's it. All node modules will no longer be bundled but will be left as require('module') .

What is bundle in node JS?

The NODEJSAPP bundle part references the JavaScript code to start the application and a Node. js application profile which are both packaged in the CICS bundle. If the Node. js application has dependencies, those dependencies must be resolved by using NPM before the bundle is enabled.

What is module bundling system?

Module bundlers are the way to organize and combine many files of JavaScript code into one file. A JavaScript bundler can be used when your project becomes too large for a single file or when you're working with libraries that have multiple dependencies.


2 Answers

There are several attempts to implement this, you can try them out and see which works best for you: bundle-up, brewer.js, connect-assetmanager

like image 185
mihai Avatar answered Nov 08 '22 15:11

mihai


Not to mention automatic complication of stylus files into a single css file, also usable as express middleware.

Search npm for 'asset' and I'm sure you can find tons of these.

like image 2
MateodelNorte Avatar answered Nov 08 '22 14:11

MateodelNorte