mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
parent
75d6c4e33a
commit
960f4fe47e
@ -78,9 +78,13 @@ Options.from = function (_options) {
|
||||
}
|
||||
|
||||
// If app.html is defined, set the template path to the user template
|
||||
options.appTemplatePath = path.resolve(options.buildDir, 'views/app.template.html')
|
||||
if (fs.existsSync(path.join(options.srcDir, 'app.html'))) {
|
||||
options.appTemplatePath = path.join(options.srcDir, 'app.html')
|
||||
if (options.appTemplatePath === undefined) {
|
||||
options.appTemplatePath = path.resolve(options.buildDir, 'views/app.template.html')
|
||||
if (fs.existsSync(path.join(options.srcDir, 'app.html'))) {
|
||||
options.appTemplatePath = path.join(options.srcDir, 'app.html')
|
||||
}
|
||||
} else {
|
||||
options.appTemplatePath = path.resolve(options.srcDir, options.appTemplatePath)
|
||||
}
|
||||
|
||||
// Ignore publicPath on dev
|
||||
|
3
test/fixtures/custom-app-template/basic.test.js
vendored
Normal file
3
test/fixtures/custom-app-template/basic.test.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
const { buildFixture } = require('../../utils/build')
|
||||
|
||||
buildFixture('custom-app-template')
|
3
test/fixtures/custom-app-template/nuxt.config.js
vendored
Normal file
3
test/fixtures/custom-app-template/nuxt.config.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
export default {
|
||||
appTemplatePath: './test/mytemplate.html'
|
||||
}
|
3
test/fixtures/custom-app-template/pages/index.vue
vendored
Normal file
3
test/fixtures/custom-app-template/pages/index.vue
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
<template>
|
||||
<h1>Custom!</h1>
|
||||
</template>
|
10
test/fixtures/custom-app-template/test/mytemplate.html
vendored
Normal file
10
test/fixtures/custom-app-template/test/mytemplate.html
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html {{ HTML_ATTRS }}>
|
||||
<head>
|
||||
{{ HEAD }}
|
||||
</head>
|
||||
<body {{ BODY_ATTRS }}>
|
||||
{{ APP }}
|
||||
<p>My Template</p>
|
||||
</body>
|
||||
</html>
|
23
test/unit/custom-app-template.test.js
Normal file
23
test/unit/custom-app-template.test.js
Normal file
@ -0,0 +1,23 @@
|
||||
import { getPort, loadFixture, Nuxt } from '../utils'
|
||||
|
||||
let port
|
||||
let nuxt = null
|
||||
|
||||
describe('custom-app-template', () => {
|
||||
beforeAll(async () => {
|
||||
const options = loadFixture('custom-app-template')
|
||||
nuxt = new Nuxt(options)
|
||||
port = await getPort()
|
||||
await nuxt.listen(port, '0.0.0.0')
|
||||
})
|
||||
test('/', async () => {
|
||||
const { html } = await nuxt.renderRoute('/')
|
||||
expect(html.includes('<p>My Template</p>')).toBe(true)
|
||||
expect(html.includes('<h1>Custom!</h1>')).toBe(true)
|
||||
})
|
||||
|
||||
// Close server and ask nuxt to stop listening to file changes
|
||||
afterAll(async () => {
|
||||
await nuxt.close()
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue
Block a user