@mapbox/batfish
Version:
The React-powered static-site generator you didn't know you wanted
23 lines (19 loc) • 576 B
JavaScript
//
;
const path = require('path');
// Get the absolute path to an asset referenced by a relative path in
// assets.json, which Webpack generates.
function getWebpackAssetAbsolutePath(
batfishConfig ,
assetPath
) {
let pathWithoutBase = assetPath;
if (batfishConfig.siteBasePath) {
pathWithoutBase = assetPath.replace(
new RegExp(`^${batfishConfig.siteBasePath}`),
''
);
}
return path.join(batfishConfig.outputDirectory, pathWithoutBase);
}
module.exports = getWebpackAssetAbsolutePath;