Feat: Add config option to run the built in server in cluster mode and to ignore some files of being added with resource hints #59
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First, thank you for this awesome vue-cli plugin!
As I wanted to run the built-in server in cluster mode I've added the config option to be able to accomplish this.
As the dev server does not need clustered mode (and also does not like it 🙈) I've adapted the
server.js
file to set up the cluster as soon as the config optionclustered
is set totrue
and theNODE_ENV
equalsproduction
. The cluster will create one worker per CPU core and also listens to the workersexit
events to be able to fork a new one if one crashes. This prevents the server to lose all of its workers in case of failure. The workers will start the server as it was before.If one of both rules does not apply, the server will launch as it was before my changes.
EDIT 1:
I've also adapted the check
isProd
inlib/webpack.js
. Before my change, the check was based on theVUE_CLI_MODE
. But as many developers have multiple custom Vue modes (in my case production, staging, and development) that all build and serve the app in the same way but with different Vue specific environment variables, I've changed the check to use theNODE_ENV
. This allows the developers to have custom Vue modes and to control the build/serve process with theNODE_ENV
.EDIT 2:
As I needed the possibility to exclude some static assets of being added to the manifests and being prefetched/preloaded I've added 2 options to specify files from being ignored accordingly to https://ssr.vuejs.org/guide/build-config.html#client-config