Skip to content
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

addWatchTarget doesn't work with npm-run-all or concurrently #1736

Open
jordanthornquest opened this issue Apr 15, 2021 · 2 comments
Open

addWatchTarget doesn't work with npm-run-all or concurrently #1736

jordanthornquest opened this issue Apr 15, 2021 · 2 comments
Labels
feature: 🪞 ignores Ignores, via configuration API or .eleventyignore or .gitignore etc needs-triage

Comments

@jordanthornquest
Copy link

jordanthornquest commented Apr 15, 2021

Describe the bug
When attempting to run Eleventy with a tool like concurrently or npm-run-all, Eleventy doesn't appear to watch targets specified via addWatchTarget. However, it does work in other parallel use cases. Some specifics:

I am running PostCSS with its --watch flag to watch my CSS files for changes. Similarly, I'm running Eleventy with its --serve flag to watch my Eleventy files for changes. These are done via two NPM scripts (npm run watch:css and npm run watch:site). I'm running the two scripts in parallel using npm run start.

I am using PostCSS to generate a file from ./src/_assets/css/style.css to ./.cache/compiled.css. I am using Eleventy's addWatchTarget feature to watch for changes to the ./.cache/compiled.css file. When changes are detected, Eleventy should trigger a rebuild. I am using PostCSS's verbose output to ensure that PostCSS is compiling the file, both when initially running npm run start and on file changes. The output confirms that PostCSS is recompiling as expected.

(It may be worth noting that I am choosing to set setUseGitIgnore to false, and I'm using a .eleventyignore file instead, which I've done in order to watch .cache/, a directory otherwise ignored.)

When using a script like npm run watch:css & npm run watch:site, Eleventy detects changes to compiled.css and rebuilds successfully. If I run npm run watch:css and npm run watch:site in separate terminal windows, I can achieve the same success.

When running the same scripts together using either concurrently or npm-run-all, Eleventy does not detect changes to compiled.css.

To Reproduce
Steps to reproduce the behavior:

  1. Clone website repository (linked to a specific commit in the project's Git history): https://github.com/jordanthornquest/jordanthornquest/tree/c86a74b53d6b687a5f99bdcfa5a57d0ca4f79620
  2. npm install
  3. npm run start
  4. Check repository to ensure PostCSS has generated ./.cache/compiled.css.
  5. View terminal output.
    • PostCSS verbose output should note that the file has been compiled.
    • Eleventy's watcher fails to recognize that the file has been updated, and doesn't trigger a build.
  6. End npm-run-start
  7. Run npm run watch:site & npm run watch:css
  8. View terminal output.
    • PostCSS verbose output should note that the file has been compiled.
    • Eleventy's watcher recognizes that the file has been updated, and triggers a build.

Expected behavior
My expectation is that running these two scripts with concurrently or npm-run-all would behave identically to running the scripts with npm run watch:css & npm run watch:site.

Environment:

  • OS and Version: macOS 11.2.3 (M1 MacBook Air)
  • Eleventy Version: v0.12.1
  • Node Version: v15.14.0
  • NPM Version: v7.7.6

Additional context:
While I'd understand assuming the issue may lie with npm-run-all or concurrently, Eleventy is the only build tool I've had this issue with. PostCSS, Dart Sass, & Rollup don't seem to have the same issue.

@pepelsbey
Copy link

FYI, I’m trying to build something similar with PostCSS, but using built-in dev server and addExtension. It still doesn’t work the way it supposed to, but I think I’m close to solving it.

@zachleat
Copy link
Member

Maybe related to #893—what’s in your .eleventyignore?

@zachleat zachleat added the feature: 🪞 ignores Ignores, via configuration API or .eleventyignore or .gitignore etc label Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: 🪞 ignores Ignores, via configuration API or .eleventyignore or .gitignore etc needs-triage
Projects
None yet
Development

No branches or pull requests

3 participants