lib/assets-processor.js
function processAssets(content, baseUrl, callback) {
  let match = ASSETS_REGEX.exec(content);

  while (match) {
    const matchString = match[0];

    let filePath;
    let filePathWithHash;

    if (isLocaleFile(matchString)) {
      filePath = resolvePhysicalLocaleFilePath(matchString);
      filePathWithHash = resolveRelativeLocaleFileDestination(
        assetsUtils.getFilePathWithHash(filePath, true)
      );
    } else {
      filePath = matchString.substring(2, matchString.length);
      filePathWithHash = assetsUtils.getFilePathWithHash(filePath, true);
    }

    if (callback) {
      callback(filePathWithHash, skyPagesConfigUtil.spaPath('src', filePath));
    }

    const url = `${baseUrl}${filePathWithHash.replace(/\\/gi, '/')}`;

    content = content.replace(
      new RegExp(matchString, 'gi'),
      url
    );

    match = ASSETS_REGEX.exec(content);
  }

  return content;
}
function processAssets(content, baseUrl, callback) {
  let match = ASSETS_REGEX.exec(content);

  while (match) {
    const matchString = match[0];

    let filePath;
    let filePathWithHash;

    if (isLocaleFile(matchString)) {
      filePath = resolvePhysicalLocaleFilePath(matchString);
      filePathWithHash = resolveRelativeLocaleFileDestination(
        assetsUtils.getFilePathWithHash(filePath, true)
      );
    } else {
      filePath = matchString.substring(2, matchString.length);
      filePathWithHash = assetsUtils.getFilePathWithHash(filePath, true);
    }

    if (callback) {
      callback(filePathWithHash, skyPagesConfigUtil.spaPath('src', filePath));
    }

    const url = `${baseUrl}${filePathWithHash.replace(/\\/gi, '/')}`;

    content = content.replace(
      new RegExp(matchString, 'gi'),
      url
    );

    match = ASSETS_REGEX.exec(content);
  }

  return content;
}
function processAssets ( content , baseUrl , callback ) { let match = ASSETS_REGEX . exec ( content ) ; while ( match ) { const matchString = match [ 0 ] ; let filePath ; let filePathWithHash ; if ( isLocaleFile ( matchString ) ) { filePath = resolvePhysicalLocaleFilePath ( matchString ) ; filePathWithHash = resolveRelativeLocaleFileDestination ( assetsUtils . getFilePathWithHash ( filePath , true ) ) ; } else { filePath = matchString . substring ( 2 , matchString . length ) ; filePathWithHash = assetsUtils . getFilePathWithHash ( filePath , true ) ; } if ( callback ) { callback ( filePathWithHash , skyPagesConfigUtil . spaPath ( 'src' , filePath ) ) ; } const url = ` ${ baseUrl } ${ filePathWithHash . replace ( / \\ / gi , '/' ) } ` ; content = content . replace ( new RegExp ( matchString , 'gi' ) , url ) ; match = ASSETS_REGEX . exec ( content ) ; } return content ; }
Finds referenced assets in a file and replaces occurrences in the file's
contents with the absolute URL.
@param {*} content The file contents.
@param {*} baseUrl The base URL where the assets will be served.
@param {*} callback A function to call for each found asset path. The function will be
provided the file path with a file hash added to the file name along with the
physical path to the file.
Finds referenced assets in a file and replaces occurrences in the file s contents with the absolute URL .