You put your preloader in, you take your preloader out, You put your preloader in, and you shake it all about...
This addon allows you to render files directly in to the index.html on the initial build, then removes them from the DOM once your app has loaded. Useful for adding a preloading screen before the initial app is downloaded.
ember install ember-preloader
The addon leverages the contentFor
helper. In your app's ember-cli-build.js define your options hash, either using the existing contentFor
hooks or your own:
var app = new EmberApp(defaults, {
preloader: {
head: 'preload.css',
body: 'preload.html'
'custom-hook': 'preload.js',
'custom-hook2': 'preload2.js'
}
});
If you've used custom hooks, add them to your index.html file:
Finally, import the mixin into your application route:
import PreloaderMixin from 'ember-preloader/mixins/preloader';
export default Route.extend(PreloaderMixin, {});
ember-cli-build.js:
var app = new EmberApp(defaults, {
preloader: {
head: 'preload.css',
body: 'preload.html',
'body-footer': 'preload.js',
}
});
Output:
<style data-preloader>
... preload.css content ...
</style>
...
<div data-preloader>
... preload.html content ...
</div>
...
<script data-preloader>
... preload.js content ...
</script>
npm run lint:hbs
npm run lint:js
npm run lint:js -- --fix
ember test
– Runs the test suite on the current Ember versionember test --server
– Runs the test suite in "watch mode"ember try:each
– Runs the test suite against multiple Ember versions
ember serve
- Visit the dummy application at http://localhost:4200.