poops 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/poops.js +16 -5
package/package.json
CHANGED
package/poops.js
CHANGED
|
@@ -206,11 +206,22 @@ async function startServer() {
|
|
|
206
206
|
await poops() // Initial compilation before starting the server
|
|
207
207
|
const app = connect()
|
|
208
208
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
209
|
+
const base = config.serve.base && pathExists(cwd, config.serve.base)
|
|
210
|
+
? path.join(cwd, config.serve.base)
|
|
211
|
+
: cwd
|
|
212
|
+
|
|
213
|
+
app.use(serveStatic(base))
|
|
214
|
+
|
|
215
|
+
// Serve 404.html for unmatched routes
|
|
216
|
+
const notFoundPage = path.join(base, '404.html')
|
|
217
|
+
app.use((req, res) => {
|
|
218
|
+
res.statusCode = 404
|
|
219
|
+
if (pathExists(notFoundPage)) {
|
|
220
|
+
fs.createReadStream(notFoundPage).pipe(res)
|
|
221
|
+
} else {
|
|
222
|
+
res.end('Not Found')
|
|
223
|
+
}
|
|
224
|
+
})
|
|
214
225
|
|
|
215
226
|
let port = overridePort || config.serve.port || 4040
|
|
216
227
|
if (!overridePort) port = await getAvailablePort(port, port + 10)
|