ember-cli-multi-html-output
Ember CLI is designed to build one single .html
file which is a compiled version of the app/index.html
file.
Sometimes, because of running the same instance of the application under different domains and/or under several environments (e.g. development
, staging
, production
), you need some texts, scripts ids... to be set for the targeted domain/environment.
This addon lets you, at the end of the application build, override and/or duplicate and then patch the generated index.html
, with values you configure in the application options.
The values replace placeholders set into app/index.html
.
Installation
ember install ember-cli-multi-html-output -D
Usage
In your app's ember-cli-build.js
, define multiIndex
options on your app instance as such:
const app = defaults multiIndex : defaults: 'LOCALE_LANGUAGE': 'de' 'LOCALE_COUNTRY': 'DE' 'LOCALE_TLD': 'de' 'SOME_TEXT': 'default': 'Some default text for dev' targets: outputPath: 'index.html' macros: 'PAGE_TITLE': 'default': 'My dev german app' 'production': 'My prod german app' 'SOME_TEXT': 'production': 'Some text for german prod' outputPath: 'index-fr.html' macros: 'LOCALE_LANGUAGE': 'fr' 'LOCALE_COUNTRY': 'FR' 'LOCALE_TLD': 'fr' 'PAGE_TITLE': 'default': 'My dev french app' 'production': 'My prod french app' 'SOME_TEXT': 'default': 'Some text for french dev' 'production': 'Some text for french prod' ;
In your app's app/index.html
PAGE_TITLE SOME_TEXT
You end up after build -env production
with:
In dist/index.html
:
My prod german app Some default text for german prod
In dist/index-fr.html
:
My prod french app Some default text for french prod
The index-fr.html
for build -env development
look like below:
My dev french app Some default text for french dev
ember build -env DESIRED_ENVIRONMENT
should be generating the different
targets (i.e index.html
, index-fr.html
) in the /dist
folder.