Skip to content

Commit

Permalink
fix: serve static webpack assets from disk in dev mode (fixes #373)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Oct 13, 2020
1 parent 1585947 commit 8298f95
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/module.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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')

0 comments on commit 8298f95

Please sign in to comment.