mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +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(
|
||||
templateFunction({
|
||||
...templateVars,
|
||||
...templateFile,
|
||||
options: {
|
||||
...templateVars.options,
|
||||
...templateFile.options
|
||||
}
|
||||
...templateFile
|
||||
})
|
||||
)
|
||||
} catch (err) {
|
||||
|
@ -10,7 +10,7 @@ export default class TemplateContext {
|
||||
constructor(builder, options) {
|
||||
this.templateFiles = Array.from(builder.template.files)
|
||||
this.templateVars = {
|
||||
options,
|
||||
nuxtOptions: options,
|
||||
extensions: options.extensions
|
||||
.map(ext => ext.replace(/^\./, ''))
|
||||
.join('|'),
|
||||
|
@ -371,8 +371,7 @@ describe('builder: builder generate', () => {
|
||||
...templateContext.templateVars,
|
||||
custom: true,
|
||||
dst: 'baz.js',
|
||||
src: '/var/nuxt/src/baz.js',
|
||||
options: {}
|
||||
src: '/var/nuxt/src/baz.js'
|
||||
})
|
||||
expect(stripWhitespace).toBeCalledTimes(3)
|
||||
expect(stripWhitespace).nthCalledWith(1, 'compiled content')
|
||||
|
@ -38,7 +38,7 @@ TemplateContext {
|
||||
"test": "test message",
|
||||
},
|
||||
"mode": "test mode",
|
||||
"options": Object {
|
||||
"nuxtOptions": Object {
|
||||
"ErrorPage": "test_error_page",
|
||||
"build": Object {
|
||||
"splitChunks": Object {
|
||||
|
Loading…
Reference in New Issue
Block a user