Skip to content

Commit

Permalink
fix(docz-core): public folder in dev mode
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Dec 19, 2018
1 parent 0caf97c commit abb3626
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -38,6 +38,7 @@
"@emotion/babel-preset-css-prop": "^10.0.5",
"@types/chokidar": "^1.7.5",
"@types/del": "^3.0.1",
"@types/express": "^4.16.0",
"@types/find-up": "^2.1.1",
"@types/fs-extra": "^5.0.4",
"@types/html-webpack-plugin": "^3.2.0",
Expand Down
1 change: 1 addition & 0 deletions packages/docz-core/package.json
Expand Up @@ -44,6 +44,7 @@
"docz-utils": "^0.13.3",
"dotenv": "^6.2.0",
"env-dot-prop": "^1.1.0",
"express": "^4.16.4",
"fast-deep-equal": "^2.0.1",
"fast-glob": "^2.2.4",
"file-loader": "^2.0.0",
Expand Down
8 changes: 6 additions & 2 deletions packages/docz-core/src/webpack/devserver.ts
@@ -1,4 +1,5 @@
import * as path from 'path'
import * as express from 'express'
import errorOverlayMiddleware from 'react-dev-utils/errorOverlayMiddleware'
import evalSourceMapMiddleware from 'react-dev-utils/evalSourceMapMiddleware'
import ignoredFiles from 'react-dev-utils/ignoredFiles'
Expand All @@ -9,13 +10,15 @@ import { ServerHooks } from '../Bundler'

export const devServerConfig = (hooks: ServerHooks, args: Args) => {
const srcPath = path.resolve(paths.root, args.src)
const publicDir = path.join(paths.root, args.public)
const publicDirPath = path.resolve(paths.root, args.public)
const publicDir = path.join(paths.root, publicDirPath)
const nonExistentDir = path.resolve(__dirname, 'non-existent')

return {
publicPath: '/',
compress: true,
clientLogLevel: args.debug ? 'info' : 'none',
contentBase: publicDir,
contentBase: [nonExistentDir],
watchContentBase: true,
hot: true,
quiet: !args.debug,
Expand All @@ -32,6 +35,7 @@ export const devServerConfig = (hooks: ServerHooks, args: Args) => {
before(app: any, server: any): void {
app.use(evalSourceMapMiddleware(server))
app.use(errorOverlayMiddleware())
app.use('/public', express.static(publicDir))
hooks.onPreCreateApp<any>(app)
},
after(app: any): void {
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Expand Up @@ -1908,7 +1908,7 @@
"@types/node" "*"
"@types/range-parser" "*"

"@types/express@*":
"@types/express@*", "@types/express@^4.16.0":
version "4.16.0"
resolved "https://registry.npmjs.org/@types/express/-/express-4.16.0.tgz#6d8bc42ccaa6f35cf29a2b7c3333cb47b5a32a19"
integrity sha512-TtPEYumsmSTtTetAPXlJVf3kEqb6wZK0bZojpJQrnD/djV4q1oB6QQ8aKvKqwNPACoe02GNiy5zDzcYivR5Z2w==
Expand Down Expand Up @@ -5479,7 +5479,7 @@ expand-tilde@^2.0.0, expand-tilde@^2.0.2:
dependencies:
homedir-polyfill "^1.0.1"

express@^4.16.2, express@^4.16.3:
express@^4.16.2, express@^4.16.3, express@^4.16.4:
version "4.16.4"
resolved "https://registry.npmjs.org/express/-/express-4.16.4.tgz#fddef61926109e24c515ea97fd2f1bdbf62df12e"
integrity sha512-j12Uuyb4FMrd/qQAm6uCHAkPtO8FDTRJZBDd5D2KOL2eLaz1yUNdUB/NOIyq0iU4q4cFarsUCrnFDPBcnksuOg==
Expand Down

0 comments on commit abb3626

Please sign in to comment.