-
Notifications
You must be signed in to change notification settings - Fork 214
Conversation
@@ -112,9 +89,6 @@ By default this middleware will start a development server with Hot Module Repla | |||
`http://localhost:5000`. To enable HMR with your application, read the documentation of corresponding Neutrino | |||
preset or middleware. | |||
|
|||
It is recommended to call this middleware only in development mode when `process.env.NODE_ENV === 'development'`. |
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.
Now that the @neutrinojs/dev-server
preset only sets the devServer
option, there's no real reason why the middleware shouldn't always be used.
* (BREAKING) Stops setting `host` / `public`, since they are only needed in a minority of use-cases (such as running inside a Docker container or having a proxy in front of webpack-dev-server), and the current implementation for them in `@neutrinojs/dev-server` is buggy. * (BREAKING) Stops supporting the `@neutrinojs/web` shorthand of setting `devServer.proxy` to a string, since it could only be used if the options it set were exactly what were required - which was often not the case given that proxy configuration is very project-specific. * Stops setting a `host` header on *responses* to the client, since it makes no sense (particularly it was set to the public host). It's possible that this was set thinking they would be set for *requests* to a proxy target, but that's not the case (and for that, `changeOrigin: true` would be more appropriate anyway). * Changes `output.publicPath` from `'./'` to `''` since the latter is equivalent (and is also the webpack default), however it correctly allows webpack-dev-server to fall back to `'/'` when needed: https://github.com/webpack/webpack-dev-server/blob/v3.1.9/lib/Server.js#L176 * Stops setting `devServer.publicPath` explicitly since it inherits from `output.publicPath` so should not normally need to be overridden: https://github.com/webpack/webpack-dev-server/blob/v3.1.9/bin/webpack-dev-server.js#L142-L152 * Stops setting `https: false`, since that's the default. Fixes #1169.
Note we may be changing this again in #1171, however I wanted to get the ~"no-op" cleanup out of the way first. |
} | ||
}; | ||
} | ||
|
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.
Should we include the headers
bit in our example? If not here, perhaps a page in the docs for "Using Neutrino with Existing SSR Architecture" would make sense.
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.
I think we could easily write several pages on how to set up SSR. Multiple other parts of the webpack config needs adjusting, eg I'm pretty sure html-webpack-plugin doesn't fully work with it out of the box and needs some experimental options enabled.
I think this example is perhaps best aimed at the more common case of "I have a standard SPA but it uses a backend and I want to proxy to it in development". (Not that it precludes adding a more advanced SSR guide somewhere else in the future)
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.
Also, perhaps an SSR guide is best suited as an extra page in webpack's docs? Ultimately Neutrino is not meant to be a replacement for all of webpack/...'s documentation, but a very thin layer of abstraction that assists with configuration generation, sets some sensible defaults, and that makes it easy to mentally map between a webpack guide and how to add that configuration via .neutrinorc.js
or via a custom Neutrino preset.
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.
#1177 :)
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.
I think we could easily write several pages on how to set up SSR
I underestimated how many pages...!
https://ssr.vuejs.org/
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.
Also: it's really 2 different things if you're talking about SSR with React/Vue vs. using webpack/neutrino for "assets", and something else for SSR of html (PHP, Ruby, etc)
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.
Yeah true
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.
Looks fantastic.
host
/public
, since they are only needed in a minority of use-cases (such as running inside a Docker container or having a proxy in front of webpack-dev-server), and the current implementation for them in@neutrinojs/dev-server
is buggy.@neutrinojs/web
shorthand of settingdevServer.proxy
to a string, since it could only be used if the options it set were exactly what were required - which was often not the case given that proxy configuration is very project-specific.host
header on responses to the client, since it makes no sense (particularly it was set to the public host). It's possible that this was set thinking they would be set for requests to a proxy target, but that's not the case (and for that,changeOrigin: true
would be more appropriate anyway).output.publicPath
from'./'
to''
since the latter is equivalent (and is also the webpack default), however it correctly allows webpack-dev-server to fall back to'/'
when needed:https://github.com/webpack/webpack-dev-server/blob/v3.1.9/lib/Server.js#L176
devServer.publicPath
explicitly since it inherits fromoutput.publicPath
so should not normally need to be overridden:https://github.com/webpack/webpack-dev-server/blob/v3.1.9/bin/webpack-dev-server.js#L142-L152
https: false
, since that's the default.Fixes #1169.