-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conditionally allow assets to be loaded without a manifest. Update README to document available options. #89
base: master
Are you sure you want to change the base?
Changes from 3 commits
2706aeb
1c4cbb7
02495b6
245f6ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,16 @@ 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` | ||
* If `true`, a <meta> tag which would eventually hold the manifest will not be inserted into the DOM. | ||
|
||
##### noManifestLookup | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the flag actually not lookup the manifest? Or is it just going to ignore any errors arising from a lookup? What is the default value? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If |
||
* Type: `boolean` | ||
* 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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,30 @@ | ||
import require from 'require'; | ||
import environment from './environment'; | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove added whitespace? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whoops. Will do. |
||
const modulePrefix = environment.modulePrefix; | ||
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the default value?