Node and Express - Asset Manager for Route Resources

I found some asset managers for node and expressed:

connect-assets , bundle-up , node.packer , node-static-asset

But they all use only one configuration to serve the concatenated and minimized assets in production. Does anyone know how to manage route-related resources with asset managers?

Say what I want:

in '/ route1' JS files 'one.js' and 'two.js'

on the '/ route2' JS files are three.js and four.js

Now I use my own β€œasset manager” as follows:

app.get('/route', function(req, res) { res.render('route', { title: 'Nice title', assets: ['jquery', 'utils', 'minifier'] // file names in JS directory }); }); 

But in this way JS files are not minimized or concatenated during production.

+4
source share
1 answer

For bundle-up it says you can use name packs. Although it still uses the configuration of a single asset, will it not technically work? Because then in the route views you can use specialized rendering for a specific route namespace.

If you use a template engine that supports inheritance (for example, Jade), you can include this resource link in a subview (along a specific route).

For a sample Jade template inheritance, see this meaning .

+4
source

Source: https://habr.com/ru/post/1394172/


All Articles