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

Using the engine’s npm run develop command doesn’t watch for changes #279

Open
adamschwartz opened this issue Oct 2, 2020 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@adamschwartz
Copy link
Contributor

adamschwartz commented Oct 2, 2020

Here’s the command as it is now:

copysrc
cd $project_path
echo "Entering .docs"
cd .docs
echo "Running npm run clean"
npm run clean
echo "Running npm run develop"
npm run develop

What it does is it copies the host project’s content into the engine’s .docs/src/content directory and then runs npm run develop in there. The problem with this is that changes to content inside src/content aren’t watched by the npm run develop watcher inside .docs.

A quick-ish hack would be to have the engine run its own watcher when you run npm run develop, and have it re-run copysrc on changes to src/content, copying files into .docs/src/content which would kick off the watcher in there. This seems like a really bad approach which is why we have not implemented it yet.

While no solution we’ve found yet is ideal, one current workaround is to run npm run develop and then once it’s running, make your changes to .docs/src/content. These will be watched by the internal npm run develop’s watcher, and everything will function normally as developers are used to. The big caveat is that once you’re done with all of your local changes, then you need to _manually copy .docs/src/content back into src/content. Worse, if you accidentally run npm run develop again (in the root) you’ll end up overwriting what you had been working on inside .docs/src/content when copysrc is called. So yea, pretty gross.

The more straight-forward alternative is to simply cancel and re-run npm run develop every time you want to see your changes. The problem with this of course is it’s slow, requiring Gatsby to start up again each time, and labor intensive as it requires you to manually run a command to see changes rather than see them change immediately.

All of this is to say, the current local development setup needs work.

@adamschwartz adamschwartz added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Oct 2, 2020
@adamschwartz
Copy link
Contributor Author

As a temporary workaround, we’ve added the npm run savechanges command (see cloudflare/cloudflare-docs@0dd348c) to make it easier to copy changes from .docs/src/content into src/content.

if [ "$1" = "savechanges" ]; then
cd $project_path
cp -r .docs/src/content/ src/content/
fi

@renandincer
Copy link
Member

Here's how I get around this issue:

  • I work entirely outside of the .docs folder
  • In parallel I run npm run develop and watch rsync -av src/content/ .docs/src/content

The second command syncs everything from the main location into .docs and if I remove or add folders it takes care of the sync. So I can move things around and delete while working no problem.

@pepe-invest-git
This comment has been minimized.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants
@adamschwartz @renandincer @pepe-invest-git and others