diff --git a/lib/module.js b/lib/module.js index 01c9318d..c53cbd51 100755 --- a/lib/module.js +++ b/lib/module.js @@ -1,3 +1,6 @@ +const { resolve } = require('path') +const serveStatic = require('serve-static') + module.exports = async function nuxtPWA (moduleOptions) { const { nuxt } = this const moduleContainer = this // TODO: remove dependency when module-utils @@ -41,6 +44,15 @@ module.exports = async function nuxtPWA (moduleOptions) { } await require(`./${name}/module.js`)(nuxt, pwa, moduleContainer) } + + // Serve dist from disk + if (nuxt.options.dev) { + const clientDir = resolve(nuxt.options.buildDir, 'dist/client') + nuxt.options.serverMiddleware.push({ + path: nuxt.options.build.publicPath, + handler: serveStatic(clientDir) + }) + } } module.exports.meta = require('../package.json')