Merge branch 'tapable' of github.com:nuxt/nuxt.js into tapable

This commit is contained in:
Sebastien Chopin 2017-06-20 15:08:26 +02:00
commit 8aaadfae79
9 changed files with 13 additions and 17 deletions

View File

@ -131,6 +131,7 @@ const defaultOptions = {
}, },
render: { render: {
ssr: {}, ssr: {},
resourceHints: true,
http2: { http2: {
push: false push: false
}, },

View File

@ -328,8 +328,14 @@ export default class Renderer extends Tapable {
if (this.options._routerBaseSpecified) { if (this.options._routerBaseSpecified) {
HEAD += `<base href="${this.options.router.base}">` HEAD += `<base href="${this.options.router.base}">`
} }
const resourceHints = context.renderResourceHints()
HEAD += resourceHints + context.renderStyles() let resourceHints = ''
if (this.options.render.resourceHints) {
resourceHints = context.renderResourceHints()
HEAD += resourceHints
}
HEAD += context.renderStyles()
APP += `<script type="text/javascript">window.__NUXT__=${serialize(context.nuxt, { isJSON: true })}</script>` APP += `<script type="text/javascript">window.__NUXT__=${serialize(context.nuxt, { isJSON: true })}</script>`
APP += context.renderScripts() APP += context.renderScripts()

View File

@ -7,7 +7,6 @@ const port = 4001
const url = (route) => 'http://localhost:' + port + route const url = (route) => 'http://localhost:' + port + route
let nuxt = null let nuxt = null
let server = null
// Init nuxt.js and create server listening on localhost:4000 // Init nuxt.js and create server listening on localhost:4000
test.before('Init Nuxt.js', async t => { test.before('Init Nuxt.js', async t => {
@ -38,6 +37,5 @@ test('/_nuxt/test.hot-update.json should returns empty html', async t => {
// Close server and ask nuxt to stop listening to file changes // Close server and ask nuxt to stop listening to file changes
test.after('Closing server and nuxt.js', async t => { test.after('Closing server and nuxt.js', async t => {
server.close() await nuxt.close()
await nuxt.close(() => {})
}) })

View File

@ -30,7 +30,7 @@ test.before('Init Nuxt.js', async t => {
server = http.createServer((req, res) => { server = http.createServer((req, res) => {
serve(req, res, finalhandler(req, res)) serve(req, res, finalhandler(req, res))
}) })
await nuxt.listen(port) server.listen(port)
}) })
test('/stateless', async t => { test('/stateless', async t => {

View File

@ -8,7 +8,6 @@ const port = 4003
const url = (route) => 'http://localhost:' + port + route const url = (route) => 'http://localhost:' + port + route
let nuxt = null let nuxt = null
let server = null
// Init nuxt.js and create server listening on localhost:4000 // Init nuxt.js and create server listening on localhost:4000
test.before('Init Nuxt.js', async t => { test.before('Init Nuxt.js', async t => {
@ -156,6 +155,5 @@ test('ETag Header', async t => {
// Close server and ask nuxt to stop listening to file changes // Close server and ask nuxt to stop listening to file changes
test.after('Closing server and nuxt.js', t => { test.after('Closing server and nuxt.js', t => {
server.close()
nuxt.close() nuxt.close()
}) })

View File

@ -6,7 +6,6 @@ const port = 4004
// const url = (route) => 'http://localhost:' + port + route // const url = (route) => 'http://localhost:' + port + route
let nuxt = null let nuxt = null
let server = null
// Init nuxt.js and create server listening on localhost:4000 // Init nuxt.js and create server listening on localhost:4000
test.before('Init Nuxt.js', async t => { test.before('Init Nuxt.js', async t => {
@ -57,6 +56,5 @@ test('/parent/validate-child?key=12345', async t => {
// Close server and ask nuxt to stop listening to file changes // Close server and ask nuxt to stop listening to file changes
test.after('Closing server and nuxt.js', t => { test.after('Closing server and nuxt.js', t => {
server.close()
nuxt.close() nuxt.close()
}) })

View File

@ -6,7 +6,6 @@ const port = 4005
const url = (route) => 'http://localhost:' + port + route const url = (route) => 'http://localhost:' + port + route
let nuxt = null let nuxt = null
let server = null
// Init nuxt.js and create server listening on localhost:4000 // Init nuxt.js and create server listening on localhost:4000
test.before('Init Nuxt.js', async t => { test.before('Init Nuxt.js', async t => {
@ -36,11 +35,11 @@ test('/404 should display an error too', async t => {
test('/ with renderAndGetWindow()', async t => { test('/ with renderAndGetWindow()', async t => {
const err = await t.throws(nuxt.renderAndGetWindow(url('/'))) const err = await t.throws(nuxt.renderAndGetWindow(url('/')))
t.is(err.response.statusCode, 500) t.true(String(err).includes('Error: socket hang up'))
// t.is(err.response.statusCode, 500)
}) })
// Close server and ask nuxt to stop listening to file changes // Close server and ask nuxt to stop listening to file changes
test.after('Closing server and nuxt.js', t => { test.after('Closing server and nuxt.js', t => {
server.close()
nuxt.close() nuxt.close()
}) })

View File

@ -7,7 +7,6 @@ const port = 4006
const url = (route) => 'http://localhost:' + port + route const url = (route) => 'http://localhost:' + port + route
let nuxt = null let nuxt = null
let server = null
// Init nuxt.js and create server listening on localhost:4000 // Init nuxt.js and create server listening on localhost:4000
test.before('Init Nuxt.js', async t => { test.before('Init Nuxt.js', async t => {
@ -40,6 +39,5 @@ test('Middleware', async t => {
// Close server and ask nuxt to stop listening to file changes // Close server and ask nuxt to stop listening to file changes
test.after('Closing server and nuxt.js', t => { test.after('Closing server and nuxt.js', t => {
server.close()
nuxt.close() nuxt.close()
}) })

View File

@ -7,7 +7,6 @@ const port = 4007
const url = (route) => 'http://localhost:' + port + route const url = (route) => 'http://localhost:' + port + route
let nuxt = null let nuxt = null
let server = null
// Init nuxt.js and create server listening on localhost:4000 // Init nuxt.js and create server listening on localhost:4000
test.before('Init Nuxt.js', async t => { test.before('Init Nuxt.js', async t => {
@ -101,6 +100,5 @@ test('Check /test.txt with custom serve-static options', async t => {
// Close server and ask nuxt to stop listening to file changes // Close server and ask nuxt to stop listening to file changes
test.after('Closing server and nuxt.js', t => { test.after('Closing server and nuxt.js', t => {
server.close()
nuxt.close() nuxt.close()
}) })