diff --git a/README.md b/README.md index 899bf5a..be464b7 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,18 @@ the asset manifest. This defaults to `[ 'js', 'css' ]`. _Note: This class provides default `contentFor`, `postprocessTree`, and `postBuild` hooks so be sure that you call `_super` if you override one of those methods._ +### Options + +##### noManifest +* Type: `boolean` +* Default: `undefined` +* If `true`, a tag which would eventually hold the manifest will not be inserted into the DOM. + +##### noManifestLookup +* Type: `boolean` +* Default: `undefined` +* If `true`, no error will be thrown in the event that a manifest was not generated for the current environment + ### Why isn't a manifest generated by default? This addon doesn't perform manifest generation just by virtue of being installed because there is no convention for diff --git a/app/config/asset-manifest.js b/app/config/asset-manifest.js index f0bbe8b..b2ce0bc 100644 --- a/app/config/asset-manifest.js +++ b/app/config/asset-manifest.js @@ -6,19 +6,24 @@ const metaName = `${modulePrefix}/config/asset-manifest`; const nodeName = `${modulePrefix}/config/node-asset-manifest`; let config = {}; +const lookupManifest = !environment.noManifestLookup; -try { - // If we have a Node version of the asset manifest, use that for FastBoot and - // similar environments. - if (require.has(nodeName)) { - config = require(nodeName).default; // eslint-disable-line - } else { - const rawConfig = document.querySelector('meta[name="' + metaName + '"]').getAttribute('content'); - config = JSON.parse(unescape(rawConfig)); +if (lookupManifest) { + try { + // If we have a Node version of the asset manifest, use that for FastBoot and + // similar environments. + if (require.has(nodeName)) { + config = require(nodeName).default; // eslint-disable-line + } else { + const rawConfig = document.querySelector('meta[name="' + metaName + '"]').getAttribute('content'); + config = JSON.parse(unescape(rawConfig)); + } + } catch(err) { + throw new Error('No manifest was found with the name "' + metaName + + '". To hide this message you can set the config option `noManifestLookup` to `true`. For non-browser environments, verify that you included the node-asset-manifest module.', { + id: 'no-manifest-found' + }); } -} catch(err) { - throw new Error('Failed to load asset manifest. For browser environments, verify the meta tag with name "'+ metaName + - '" is present. For non-browser environments, verify that you included the node-asset-manifest module.'); } export default config;