ember-fastboot / ember-fastboot/ember-cli-fastboot

postBuild modification of index.html blown away by live reload

Open
#750 0 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.