Package Exports
- asset-extensions
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (asset-extensions) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
asset-extensions
A list of extensions for web assets.
Installation
npm install asset-extensions
Usage
const assetExtensions = require('asset-extensions');
const fontExtensions = require('asset-extensions/lib/font');
const imageExtensions = require('asset-extensions/lib/image');
const scriptExtensions = require('asset-extensions/lib/script');
const styleExtensions = require('asset-extensions/lib/style');
const isPathAsset = require('asset-extensions/lib/util/isPathAsset');
Example
Connect middleware to set HTTP response headers:
const isPathAsset = require('asset-extensions/util/isPathAsset');
const imageExtensions = require('asset-extensions/image');
module.exports = (req, res, next) => {
const isAsset = isPathAsset(req.url)
const isImage = isPathAsset(req.url, imageExtensions)
if (!isPathAsset(req.url)) {
res.setHeader('Content-Security-Policy', '...');
}
if (isPathAsset(req.url, imageExtensions)) {
res.setHeader('Cache-Control', '...');
}
next();
};