express-vue / express-vue

Vue rendering engine for Express.js. Use .Vue files as templates using streams

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Document webpack renderer

nathanfallet opened this issue · comments

I was trying to migrate to webpack renderer because of a warning on app start, and i noticed it was not evident to do it. It could be great to explain how to do it with more details.

I got issues with expressVue.use() method and res.renderVue() after trying to migrate (which were working before)

Here's an example from my app, I struggled with it a bit too. Hope this helps.

expressVue
  .use(app, {
    pagesPath: path.join(__dirname, 'views'),
    head: {
      title: 'App Title',
      styles: [{ style: 'https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css' }],
      scripts: [
        { src: 'https://js.stripe.com/v3/' },
        { src: 'https://kit.fontawesome.com/b9716c1ee6.js', crossorigin: 'anonymous' },
        { src: 'https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js' },
      ],
    },
  })
  .then((app) => {
    app.use(require('./routes'))

    app.use(function (err, req, res, next) {
      res.status(err.status || 500)

      res.json({
        errors: {
          message: err.message,
          error: err,
        },
      })
    })

    app.listen(config.applicationPort, () => {
      console.log(`App listening at http://localhost:${config.applicationPort}`)
    })
  })