Skip to content

Commit 8298f95

Browse files
committed
fix: serve static webpack assets from disk in dev mode (fixes #373)
1 parent 1585947 commit 8298f95

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/module.js

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
const { resolve } = require('path')
2+
const serveStatic = require('serve-static')
3+
14
module.exports = async function nuxtPWA (moduleOptions) {
25
const { nuxt } = this
36
const moduleContainer = this // TODO: remove dependency when module-utils
@@ -41,6 +44,15 @@ module.exports = async function nuxtPWA (moduleOptions) {
4144
}
4245
await require(`./${name}/module.js`)(nuxt, pwa, moduleContainer)
4346
}
47+
48+
// Serve dist from disk
49+
if (nuxt.options.dev) {
50+
const clientDir = resolve(nuxt.options.buildDir, 'dist/client')
51+
nuxt.options.serverMiddleware.push({
52+
path: nuxt.options.build.publicPath,
53+
handler: serveStatic(clientDir)
54+
})
55+
}
4456
}
4557

4658
module.exports.meta = require('../package.json')

0 commit comments

Comments
 (0)