-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
952bbe9
commit 9ebe65d
Showing
9 changed files
with
641 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Application } from 'express' | ||
import * as errorOverlayMiddleware from 'react-dev-utils/errorOverlayMiddleware' | ||
import * as paths from './paths' | ||
|
||
export const PORT = 3000 | ||
export const PROTOCOL = process.env.HTTPS === 'true' ? 'https' : 'http' | ||
export const HOST = process.env.HOST || '0.0.0.0' | ||
|
||
export const devServerConfig = () => ({ | ||
compress: true, | ||
clientLogLevel: 'none', | ||
contentBase: paths.PLAYGRODD, | ||
watchContentBase: true, | ||
hot: true, | ||
quiet: true, | ||
noInfo: true, | ||
publicPath: '/', | ||
https: PROTOCOL === 'https', | ||
host: HOST, | ||
overlay: false, | ||
watchOptions: { | ||
ignored: /node_modules/, | ||
}, | ||
stats: { | ||
colors: true, | ||
chunks: false, | ||
chunkModules: false, | ||
}, | ||
historyApiFallback: { | ||
disableDotRule: true, | ||
}, | ||
before(app: Application) { | ||
app.use(errorOverlayMiddleware()) | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,14 @@ | ||
import { Arguments } from 'yargs' | ||
import * as express from 'express' | ||
import * as hotMiddleware from 'webpack-hot-middleware' | ||
import * as devServerMiddleware from 'webpack-dev-middleware' | ||
import * as historyApiFallback from 'connect-history-api-fallback' | ||
import * as WebpackDevServer from 'webpack-dev-server' | ||
|
||
import { entriesMapper } from './compiler' | ||
import { createCompiler } from './compiler' | ||
import { devServerConfig } from './config/dev-server' | ||
|
||
export const server = async ({ files: pattern }: Arguments) => { | ||
const app = express() | ||
const entries = await entriesMapper(pattern) | ||
const compiler = await createCompiler(entries) | ||
const server = new WebpackDevServer(compiler, devServerConfig()) | ||
|
||
const opts = { | ||
publicPath: '/', | ||
logLevel: 'warn', | ||
watchOptions: { | ||
ignored: /node_modules/, | ||
}, | ||
headers: { | ||
'Access-Control-Allow-Origin': '*', | ||
}, | ||
} | ||
|
||
app.use(historyApiFallback()) | ||
app.use(devServerMiddleware(compiler, opts)) | ||
app.use(hotMiddleware(compiler, { log: false, heartbeat: 2000 })) | ||
|
||
app.listen(3000, () => { | ||
console.log('Example app listening on port 3000!') | ||
}) | ||
server.listen(3000) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare module 'react-dev-utils/errorOverlayMiddleware' | ||
declare module 'react-dev-utils/WebpackDevServerUtils' |
Oops, something went wrong.