-
-
Notifications
You must be signed in to change notification settings - Fork 375
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
Feature: Watch mode without dev server #1427
Feature: Watch mode without dev server #1427
Conversation
🦋 Changeset is good to goLatest commit: 95e36a9 We got this. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
A few changes are purely code-style based that my IDE caught. I figure I won't revert them for now as they do look to be correct changes, but I can undo this if it makes the PR too messy. |
I'd need to come back to look at this again. |
What kind of change does this PR introduce?
Feature
Did you add tests for your changes?
Yes. I added a test under
watch.test.js
that will run the file watcher and check to see if the built output is updated after a change occurs to the source. I figure this approach is simpler than the alternatives and still ensures the functionality works. So long as the built output changes the feature should be fine. I don't think we need a browser test.Summary
This builds upon #1264 which leads back to & would close #1248.
Currently, the experience for developing SSR apps using the Preact CLI isn't great. To produce a bundle that can be used a developer needs to run the full production build and then rerun it on every change. This is slow and un-automated.
A solution, as pointed out by @oliverstr, is to provide an option to disable the dev server in
watch
mode. Any changes to the source would have the CLI rebuild and developers can consume the build in any way that they please.@oliverstr's PR for implementing this feature (#1264) has been untouched since June 29th so I figure at this point it is fair to step in and try to complete. His PR had a few issues, besides being behind the current head, namely, it would not clear the
build/
directory, leading to a large build up of temporary files, it ignored changes tosrc/*
by default, and it could not handle CSS imports without wrapping them in a window check (if (typeof window !== "undefined") { ... }
). I have fixed all three of these issues and a few more that popped up along the way to finish off his feature.You can use the following repo to try this out, though you'll need to bring your own CLI copy with linking or relative paths. Simple server set up with Polka and Nodemon. Simply run
yarn serve:dev
in one terminal window andyarn serve
in another.serve:dev
starts the CLI watch mode,serve
starts Polka with Nodemon. Nothing fancy.ryanchristian4427/preact-cli-watch-without-devserver
Does this PR introduce a breaking change?
No breaking changes. This feature is behind a flag.