Skip to content

Commit 1ea5dae

Browse files
authored
fix build reloading (#1211)
* fix build reloading * prettier * fix build reloading
1 parent 21310bd commit 1ea5dae

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

packages/webawesome/docs/.eleventy.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,12 @@ export default async function (eleventyConfig) {
229229
// eleventyConfig.addPlugin(formatCodePlugin());
230230
// }
231231

232-
let assetsDir = path.join(process.env.BASE_DIR || 'docs', 'assets');
233-
const siteAssetsDir = path.join(eleventyConfig.directories.output, 'assets');
234-
fs.cpSync(assetsDir, siteAssetsDir, { recursive: true });
232+
// This needs to happen in "eleventy.after" otherwise incremental builds never update.
233+
eleventyConfig.on('eleventy.after', function () {
234+
let assetsDir = path.join(process.env.BASE_DIR || 'docs', 'assets');
235+
const siteAssetsDir = path.join(eleventyConfig.directories.output, 'assets');
236+
fs.cpSync(assetsDir, siteAssetsDir, { recursive: true });
237+
});
235238

236239
for (let glob of passThrough) {
237240
eleventyConfig.addPassthroughCopy(glob);

packages/webawesome/scripts/build.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ export async function build(options = {}) {
398398
return async filename => {
399399
const changedFile = relative(getRootDir(), filename);
400400

401-
if (evt === 'changed') {
401+
if (evt === 'change') {
402402
spinner.info(`File modified ${chalk.gray(`(${changedFile})`)}`);
403403
} else if (evt === 'unlink') {
404404
spinner.info(`File deleted ${chalk.gray(`(${changedFile})`)}`);
@@ -470,7 +470,7 @@ export async function build(options = {}) {
470470
}
471471
await generateDocs({ spinner });
472472

473-
if (typeof options.beforeWatchEvent === 'function') {
473+
if (typeof options.afterWatchEvent === 'function') {
474474
await options.afterWatchEvent(evt, filename);
475475
}
476476
reload();

0 commit comments

Comments
 (0)