-
Notifications
You must be signed in to change notification settings - Fork 10
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
Server Plugin API #471
Server Plugin API #471
Conversation
e3d7af2
to
99dc9cc
Compare
99dc9cc
to
abd8ee4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, this is definitely a great start and is pretty much mostly complete from what i can see! (aside from needing some docs and considering the below feedback 👇 )
One thought here is that if we can extract the livereload <script>
tag snippet out of our standard HTML plugin, we could completely encapsulate all the related functionality. 🎉
So the export
could be something like this:
class LiveReloadServer extends ServerInterface {
...
}
class LiveReloadResource extends ResourceInterface {
...
}
module.exports = (options = {}) => {
return [{
type: 'server',
name: 'plugin-live-reload-server',
provider: (compilation) => new LiveReloadServer(compilation, options)
}, {
type: 'resource',
name: 'plugin-live-reload-resource',
provider: (compilation) => new LiveReloadResource(compilation, options)
}]
};
And greenwood.config.js would look something like this.
const pluginLiveReload = require('./packages/cli/src/plugins/server/plugin-livereload');
module.exports = {
plugins: [
...pluginLiveReload({ /* options */ }) // notice the spread! ...
]
};
I'm sure it could get more elegant with some extra thought, but this definitely gets the job done for now and is pretty effective, IMO.
What I really like about being able to combine it all into one is that later on, I would like to introduce a HotModuleReplacement (HMR) plugin, and thus allow user's the option to choose which developer experience they would like, would be 👌
On a related note about extracting LiveReload from the CLI down the road, is that we will likely want to deprecate devServer
from greenwood.config.js since likely each server plugin will have its own unique configuration needs. I think this is good though, since it cleanly moves things out of core and into plugins, which is quite nice. 😃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some docs and refactored to make plugin-livereload a Greenwood default server plugin (for now at least).
I will rebase this branch against the release/0.10.0
branch, but will let my changes stand until we can review during this week's meeting, at which point I think then this will be good to merge, barring any major objections.
9b32276
to
1fa9dc0
Compare
* task: adding initial server api * fix lint and cases * refactor live reload to be internal plugin * server plugin docs * updates post ResourceInterface changes from release branch Co-authored-by: Owen Buckley <[email protected]>
* task: adding initial server api * fix lint and cases * refactor live reload to be internal plugin * server plugin docs * updates post ResourceInterface changes from release branch Co-authored-by: Owen Buckley <[email protected]>
Related Issue
Resolves #470
Summary of Changes
ServerInterface
type: "server"
start()
function from plugin when running greenwood in development modeTHIS IS JUST A PROTOTYPE /POC