mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-17 06:01:34 +00:00
refactor(builder): pass nuxt options to template as nuxtOptions
(#5792)
This commit is contained in:
parent
6e9cf8e394
commit
737d5f0fe7
@ -514,11 +514,7 @@ export default class Builder {
|
|||||||
content = stripWhitespace(
|
content = stripWhitespace(
|
||||||
templateFunction({
|
templateFunction({
|
||||||
...templateVars,
|
...templateVars,
|
||||||
...templateFile,
|
...templateFile
|
||||||
options: {
|
|
||||||
...templateVars.options,
|
|
||||||
...templateFile.options
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -10,7 +10,7 @@ export default class TemplateContext {
|
|||||||
constructor(builder, options) {
|
constructor(builder, options) {
|
||||||
this.templateFiles = Array.from(builder.template.files)
|
this.templateFiles = Array.from(builder.template.files)
|
||||||
this.templateVars = {
|
this.templateVars = {
|
||||||
options,
|
nuxtOptions: options,
|
||||||
extensions: options.extensions
|
extensions: options.extensions
|
||||||
.map(ext => ext.replace(/^\./, ''))
|
.map(ext => ext.replace(/^\./, ''))
|
||||||
.join('|'),
|
.join('|'),
|
||||||
|
@ -371,8 +371,7 @@ describe('builder: builder generate', () => {
|
|||||||
...templateContext.templateVars,
|
...templateContext.templateVars,
|
||||||
custom: true,
|
custom: true,
|
||||||
dst: 'baz.js',
|
dst: 'baz.js',
|
||||||
src: '/var/nuxt/src/baz.js',
|
src: '/var/nuxt/src/baz.js'
|
||||||
options: {}
|
|
||||||
})
|
})
|
||||||
expect(stripWhitespace).toBeCalledTimes(3)
|
expect(stripWhitespace).toBeCalledTimes(3)
|
||||||
expect(stripWhitespace).nthCalledWith(1, 'compiled content')
|
expect(stripWhitespace).nthCalledWith(1, 'compiled content')
|
||||||
|
@ -38,7 +38,7 @@ TemplateContext {
|
|||||||
"test": "test message",
|
"test": "test message",
|
||||||
},
|
},
|
||||||
"mode": "test mode",
|
"mode": "test mode",
|
||||||
"options": Object {
|
"nuxtOptions": Object {
|
||||||
"ErrorPage": "test_error_page",
|
"ErrorPage": "test_error_page",
|
||||||
"build": Object {
|
"build": Object {
|
||||||
"splitChunks": Object {
|
"splitChunks": Object {
|
||||||
|
Loading…
Reference in New Issue
Block a user