new-webpack: allow running in dev (#565)

Summary:
In addition to simply disabling the prod-only check, we apply a
workaround for a known bug that breaks static site generation in Webpack
versions >= 2.0.

Test Plan:
Run

```
NODE_ENV=development node ./node_modules/.bin/webpack-dev-server \
    --config config/makeWebpackConfig.js
```

and visit http://localhost:8080/webpack-dev-server/ (note the trailing
slash) or just http://localhost:8080/. Expect the server to be slow, as
it is actually building for production.

wchargin-branch: webpack-enable-dev
This commit is contained in:
William Chargin 2018-07-30 16:26:13 -07:00 committed by GitHub
parent 7bf0ed3c84
commit fca43f4362
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,15 +21,6 @@ const publicUrl = publicPath.slice(0, -1);
// Get environment variables to inject into our app.
const env = getClientEnvironment(publicUrl);
// Assert this just to be safe.
// Development builds of React are slow and not intended for production.
if (env.stringified["process.env"].NODE_ENV !== '"production"') {
throw new Error("Production builds must have NODE_ENV=production.");
}
// This is the production configuration.
// It compiles slowly and is focused on producing a fast and minimal bundle.
// The development configuration is different and lives in a separate file.
function makeConfig(_unused_mode /*: "production" | "development" */) {
return {
// Don't attempt to continue if there are any errors.
@ -45,6 +36,9 @@ function makeConfig(_unused_mode /*: "production" | "development" */) {
paths.appServerSideRenderingIndexJs,
],
},
devServer: {
inline: false,
},
output: {
// The build folder.
path: paths.appBuild,