ember-fastboot / ember-fastboot/ember-cli-fastboot
postBuild modification of index.html blown away by live reload
- Dominant language
- JavaScript
- Stars
- 850
- Forks
- 161
- Avg merge
- 17h 45m
- Merged PRs (30d)
- 19
Description
I have an addon that modifies the generated html files in the `postBuild()` hook.
That generally works fine with FastBoot, however if I change a file and `ember s` reloads the page, these changes are not applied. I can see in the console (if I add some debug statements) that the `postBuild()` hook is correctly called again, but the generated HTML page is as if the `postBuild()` hook would not be present.
A simplified example - this is an in-repo addon:
```js
module.exports = {
name: require('./package').name,
postBuild(build) {
let htmlFiles = filterHtmlFiles(build.directory);
htmlFiles.forEach((file) => replaceMetaTag(file));
}
};
replaceMetaTag(filePath) {
let fileBody = fs.readFileSync(filePath, { encoding: 'utf-8' });
let regex = /<\/meta>/gm;
fs.writeFileSync(filePath, fileBody.replace(regex, 'something else'));
}
```
When I run `ember s` I get a correct output by Fastboot, everything is as expected. But when I change anything and live reload rebuilds the page, I can see that `replaceMetaTag` is correctly called, but the then newly generated HTML page from FastBoot is as if it never ran.
Contributor guide
Assessment
This issue has not been assessed yet.