mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
Remove JS files for pages & layouts
This commit is contained in:
parent
e3eb83d669
commit
af60ba21c0
@ -1,7 +1,7 @@
|
||||
export default {
|
||||
render (h) {
|
||||
return <div>
|
||||
<h1>Welcome!</h1>
|
||||
<h1>Welcome !</h1>
|
||||
<nuxt-link to="/about">About page</nuxt-link>
|
||||
</div>
|
||||
}
|
||||
|
@ -73,6 +73,7 @@ export function getContext (context, app) {
|
||||
let ctx = {
|
||||
isServer: !!context.isServer,
|
||||
isClient: !!context.isClient,
|
||||
isStatic: process.static,
|
||||
isDev: <%= isDev %>,
|
||||
app: app,
|
||||
<%= (store ? 'store: context.store,' : '') %>
|
||||
|
@ -190,7 +190,7 @@ export function cleanChildrenRoutes (routes, isChild = false) {
|
||||
export function createRoutes (files, srcDir) {
|
||||
let routes = []
|
||||
files.forEach((file) => {
|
||||
let keys = file.replace(/^pages/, '').replace(/\.(vue|js)$/, '').replace(/\/{2,}/g, '/').split('/').slice(1)
|
||||
let keys = file.replace(/^pages/, '').replace(/\.vue$/, '').replace(/\/{2,}/g, '/').split('/').slice(1)
|
||||
let route = { name: '', path: '', component: r(srcDir, file) }
|
||||
let parent = routes
|
||||
keys.forEach((key, i) => {
|
||||
|
@ -26,11 +26,6 @@ test('/stateless', async t => {
|
||||
t.true(html.includes('<h1>My component!</h1>'))
|
||||
})
|
||||
|
||||
test('/jsfile', async t => {
|
||||
const { html } = await nuxt.renderRoute('/jsfile')
|
||||
t.true(html.includes('<span>support js pages</span>'))
|
||||
})
|
||||
|
||||
/*
|
||||
** Example of testing via dom checking
|
||||
*/
|
||||
|
5
test/fixtures/basic/pages/jsfile.js
vendored
5
test/fixtures/basic/pages/jsfile.js
vendored
@ -1,5 +0,0 @@
|
||||
export default {
|
||||
render (h) {
|
||||
return h('span', ['support js pages'])
|
||||
}
|
||||
}
|
10
test/fixtures/with-config/layouts/js.js
vendored
10
test/fixtures/with-config/layouts/js.js
vendored
@ -1,10 +0,0 @@
|
||||
export default {
|
||||
render () {
|
||||
return (
|
||||
<div>
|
||||
<h1>JS layout</h1>
|
||||
<nuxt/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
11
test/fixtures/with-config/pages/js.js
vendored
11
test/fixtures/with-config/pages/js.js
vendored
@ -1,11 +0,0 @@
|
||||
export default {
|
||||
layout: 'js',
|
||||
render () {
|
||||
return (
|
||||
<div>
|
||||
<h1>About JS page</h1>
|
||||
<nuxt-link to="/">Home page</nuxt-link>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
@ -38,7 +38,7 @@ test('/ (custom app.html)', async t => {
|
||||
|
||||
test('/ (custom build.publicPath)', async t => {
|
||||
const { html } = await nuxt.renderRoute('/')
|
||||
t.true(html.includes('src="/test/orion/vendor.bundle'))
|
||||
t.true(html.includes('src="/test/orion/vendor.'))
|
||||
})
|
||||
|
||||
test('/test/ (router base)', async t => {
|
||||
@ -57,14 +57,6 @@ test('/test/about (custom layout)', async t => {
|
||||
t.true(html.includes('<h1>About page</h1>'))
|
||||
})
|
||||
|
||||
test('/test/js (custom js layout)', async t => {
|
||||
const window = await nuxt.renderAndGetWindow(url('/test/js'))
|
||||
const html = window.document.body.innerHTML
|
||||
t.is(window.__NUXT__.layout, 'js')
|
||||
t.true(html.includes('<h1>JS layout</h1>'))
|
||||
t.true(html.includes('<h1>About JS page</h1>'))
|
||||
})
|
||||
|
||||
test('/test/env', async t => {
|
||||
const window = await nuxt.renderAndGetWindow(url('/test/env'))
|
||||
const html = window.document.body.innerHTML
|
||||
@ -95,7 +87,7 @@ test('/test/about-bis (added with extendRoutes)', async t => {
|
||||
|
||||
test('Check stats.json generated by build.analyze', t => {
|
||||
const stats = require(resolve(__dirname, 'fixtures/with-config/.nuxt/dist/stats.json'))
|
||||
t.is(stats.assets.length, 31)
|
||||
t.is(stats.assets.length, 27)
|
||||
})
|
||||
|
||||
test('Check /test.txt with custom serve-static options', async t => {
|
||||
|
Loading…
Reference in New Issue
Block a user