Add transition hooks in nuxt.config.js

This commit is contained in:
Sébastien Chopin 2017-01-13 21:30:31 +01:00
parent 8f29fe6a54
commit 2d85b53266
2 changed files with 5 additions and 2 deletions

View File

@ -41,7 +41,7 @@ require('<%= pluginPath %>')
// root instance
// here we inject the router and store to all child components,
// making them available everywhere as `this.$router` and `this.$store`.
const defaultTransition = <%= JSON.stringify(transition) %>
const defaultTransition = <%= serialize(transition) %>
const app = {
router,
<%= (store ? 'store,' : '') %>

View File

@ -8,6 +8,7 @@ import fs from 'fs-extra'
import hash from 'hash-sum'
import pify from 'pify'
import webpack from 'webpack'
import serialize from 'serialize-javascript'
import { createBundleRenderer } from 'vue-server-renderer'
import { join, resolve, sep } from 'path'
import clientWebpackConfig from './webpack/client.config.js'
@ -199,7 +200,9 @@ function * generateRoutesAndFiles () {
let moveTemplates = templatesFiles.map((file) => {
return readFile(r(__dirname, 'app', file), 'utf8')
.then((fileContent) => {
const template = _.template(fileContent)
const template = _.template(fileContent, {
imports: { serialize }
})
const content = template(templateVars)
return writeFile(r(this.dir, '.nuxt', file), content, 'utf8')
})