packages/subapp-server/lib/utils.js
/**
 * Load stats.json which is created during build.
 * Attempt to load the stats.json file which contains a manifest of
 * The file contains bundle files which are to be loaded on the client side.
 *
 * @param {string} statsPath - path of stats.json
 * @returns {Promise.<Object>} an object containing an array of file names
 */
Load stats.json which is created during build.
Attempt to load the stats.json file which contains a manifest of
The file contains bundle files which are to be loaded on the client side.

@param {string} statsPath - path of stats.json
@returns {Promise.} an object containing an array of file names
Load stats . json which is created during build . Attempt to load the stats . json file which contains a manifest of The file contains bundle files which are to be loaded on the client side . @param { string } statsPath - path of stats . json @returns { Promise . } an object containing an array of file names
function loadAssetsFromStats(statsPath) {
  let stats;
  try {
    stats = JSON.parse(Fs.readFileSync(Path.resolve(statsPath)).toString());
  } catch (err) {
    return {};
  }
  const assets = {};
  const manifestAsset = _.find(stats.assets, asset => {
    return asset.name.endsWith("manifest.json");
  });
  const jsAssets = stats.assets.filter(asset => {
    return asset.name.endsWith(".js");
  });
  const cssAssets = stats.assets.filter(asset => {
    return asset.name.endsWith(".css");
  });
  if (manifestAsset) {
    assets.manifest = manifestAsset.name;
  }
  assets.js = jsAssets;
  assets.css = cssAssets;
  assets.byChunkName = stats.assetsByChunkName;
  return assets;
}
function loadAssetsFromStats ( statsPath ) { let stats ; try { stats = JSON . parse ( Fs . readFileSync ( Path . resolve ( statsPath ) ) . toString ( ) ) ; } catch ( err ) { return { } ; } const assets = { } ; const manifestAsset = _ . find ( stats . assets , asset => { return asset . name . endsWith ( "manifest.json" ) ; } ) ; const jsAssets = stats . assets . filter ( asset => { return asset . name . endsWith ( ".js" ) ; } ) ; const cssAssets = stats . assets . filter ( asset => { return asset . name . endsWith ( ".css" ) ; } ) ; if ( manifestAsset ) { assets . manifest = manifestAsset . name ; } assets . js = jsAssets ; assets . css = cssAssets ; assets . byChunkName = stats . assetsByChunkName ; return assets ; }
Load stats.json which is created during build.
Load stats . json which is created during build .