-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Remove hardcoded index.html
value
#2523
Remove hardcoded index.html
value
#2523
Conversation
tests please |
I would prefer to use |
var files = [ | ||
'index.html' | ||
HTMLRootFile |
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.
indexPath or indexName ?
if we make this change, it will need to also submit a PR to the website. |
Basically something like: /* global require, module */
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
var app = new EmberApp({
outputPaths: {
app: {
html: 'some-other-thing.html'
}
}
});
module.exports = app.toTree(); |
@rwjblue +1 |
@rwjblue 👍 |
This would also really help for apps that are hosted in something like ServiceStack where the index.html needs to be serverside rendered to pre-populate a preloadStore |
I'll modify the PR to use the |
tests please, and docs in a separate PR to the website. I would like to get it in for tonight's potential release. |
PR updated with tests |
👍 lGTm |
@@ -269,7 +269,7 @@ describe('Acceptance: brocfile-smoke-test', function() { | |||
}); | |||
}); | |||
|
|||
it('specifying custom output paths works properly', function() { | |||
it.only('specifying custom output paths works properly', function() { |
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.
it.only
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.
good catch.
@rwjblue I can't really get the idea to work that If we want to keep the If I keep diff --git a/lib/broccoli/ember-app.js b/lib/broccoli/ember-app.js
index 53107f5..ade119c 100644
--- a/lib/broccoli/ember-app.js
+++ b/lib/broccoli/ember-app.js
@@ -280,7 +280,7 @@ EmberApp.prototype.populateLegacyFiles = function () {
EmberApp.prototype.index = function() {
var htmlName = this.options.outputPaths.app.html;
var files = [
- htmlName
+ 'index.html'
];
var index = pickFiles(this.trees.app, { diff --git a/tests/acceptance/brocfile-smoke-test-slow.js b/tests/acceptance/brocfile-smoke-test-slow.js
index eda4fe0..9ee7e38 100644
--- a/tests/acceptance/brocfile-smoke-test-slow.js
+++ b/tests/acceptance/brocfile-smoke-test-slow.js
@@ -282,13 +282,6 @@ describe('Acceptance: brocfile-smoke-test', function() {
var appCSS = fs.readFileSync(appCSSPath);
return fs.writeFileSync(themeCSSPath, appCSS);
})
- .then(function () {
- // copy index.html to my-app.html
- var indexHTMLPath = path.join(__dirname, '..', '..', 'tmp', appName, 'app', 'index.html');
- var myAppHTMLPath = path.join(__dirname, '..', '..', 'tmp', appName, 'app', 'my-app.html');
- var appHTML = fs.readFileSync(indexHTMLPath);
- return fs.writeFileSync(myAppHTMLPath, appHTML);
- })
.then(function() {
return runCommand(path.join('.', 'node_modules', 'ember-cli', 'bin', 'ember'), 'build', {
verbose: true Then the tests fails fail. I agree that that's the behavior we want. But my knowledge about the ember-cli build process is really too limited. I could really use some help and pointers to get this PR working and merged |
@rwjblue I executed a crazy idea in mynewsdesk/ember-cli@21f8ebb that seems stable. Thoughts? |
@@ -287,9 +289,21 @@ EmberApp.prototype.index = function() { | |||
destDir: '/' | |||
}); | |||
|
|||
index = new Funnel(index, { | |||
srcDir: '/', |
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.
This is the default for broccoli-funnel, no need to specify.
@teoljungberg - Crazy like a fox ;) That is exactly what I was typing up as a suggestion! |
@rwjblue pushed and fixed. Deleting code is always satisfying |
var files = [ | ||
'index.html' | ||
]; | ||
|
||
var index = pickFiles(this.trees.app, { | ||
index = new Funnel(this.tress.app, { |
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.
need the var
here I think
@rwjblue I rebased against master and pushed fixes to your comment |
Awesome! Can you squash the commits? Then I'll hit the big green button once Travis passes... |
@rwjblue sure thing - consider it done! |
This allows the generated html file to be renamed however is needed. This is exceptionally helpful for configuring how the root HTML file should be cached, since the `index.html` is cached harshly by most web servers To use it, configure `outputPaths.app.html` in your `Brocfile.js` file: var EmberApp = require('ember-cli/lib/broccoli/ember-app'); var app = new EmberApp({ outputPaths: { app: { html: 'custom-name.html' }, } }); module.exports = app.toTree();
I force pushed over a few typos and squashed the commits into 2, 1 for the actual change and 1 for the addition to the changelog @rwjblue |
Awesome, thank you! |
Remove hardcoded `index.html` value
👍 Thank you very much @teoljungberg, been looking for something like this. Tried to implement myself, but not familiar enough with Broccoli. |
Thanks for this. Wouldn't we want the express dev server to use this configuration to serve its root file? Or is that not always desirable? |
@gdub22 - Yes, we absolutely would like the express server to use this for its history support. Unfortunately, configuration made in the Brocfile.js is not available in the express server. This is yet another issue to be solved by the upcoming configuration refactoring. |
@teoljungberg Thanks for this! |
This allows the generated html file to be renamed however is needed.
This is exceptionally helpful for configuring how the root HTML file
should be cached, since the
index.html
is cached harshly by most webservers
To use it, configure
outputPaths.app.html
in yourBrocfile.js
file: