UNPKG

cdnjs-env

Version:

Use full / minified versions of CDNJS libraries based on the environment.

17 lines (13 loc) 314 B
'use strict' exports.url = (lib) => { if (process.env.NODE_ENV === 'production') { return lib.replace(/(\.min)?(\.[a-z]+)$/i, '.min$2') } return lib.replace(/(\.min)?(\.[a-z]+)$/i, '$2') } exports.middleware = () => { return (req, res, next) => { res.locals.cdnjs = exports.url next() } }