bower-to-locals

adds all bower mainfiles to res.locals

Usage no npm install needed!

<script type="module">
  import bowerToLocals from 'https://cdn.skypack.dev/bower-to-locals';
</script>

README

bowerToLocals

A simple middleware to select all Bower main files and saves them into the response.locals Object.

Install

npm install bower-to-locals

How to use

var express = require('express');
var app = express();

require('bower-to-locals').init(app);

To see all the current seleced files:

var express = require('express');
var app = express();
var bowerToLocals = require('bower-to-locals');
bowerToLocals.init(app);
 
if(app.env === 'development'){
  console.log(bowerToLocals.list());
}
 ---- start section bower-to-locals ----
bootstrap.less
bootstrap.css
bootstrap.js
bootstrap.eot
bootstrap.svg
bootstrap.ttf
bootstrap.woff
jquery
---- end section ----

In a jade file for example:

script(src=jquery)
script(src=bootstrap.js)

Minify

Js

To minify js just call minify after init

var express = require('express');
var app = express();
var bowerToLocals = require('bower-to-locals');
bowerToLocals.init(app);
bowerToLocals.minify();