mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 09:27:13 +00:00
internal refactors
This commit is contained in:
parent
bdca7630a4
commit
be4d8c5e13
@ -5,3 +5,8 @@ export default {
|
|||||||
Builder,
|
Builder,
|
||||||
Generator
|
Generator
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
Builder,
|
||||||
|
Generator
|
||||||
|
}
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
import * as Utils from './utils'
|
import * as Utils from './utils'
|
||||||
|
import Options from './options'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
Utils
|
Utils,
|
||||||
|
Options
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
Utils,
|
||||||
|
Options
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ export default function Options (_options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Apply defaults
|
// Apply defaults
|
||||||
_.defaultsDeep(options, defaultOptions)
|
_.defaultsDeep(options, Options.defaults)
|
||||||
|
|
||||||
// Resolve dirs
|
// Resolve dirs
|
||||||
options.rootDir = (typeof options.rootDir === 'string' && options.rootDir ? options.rootDir : process.cwd())
|
options.rootDir = (typeof options.rootDir === 'string' && options.rootDir ? options.rootDir : process.cwd())
|
||||||
@ -38,7 +38,7 @@ export default function Options (_options) {
|
|||||||
// Ignore publicPath on dev
|
// Ignore publicPath on dev
|
||||||
/* istanbul ignore if */
|
/* istanbul ignore if */
|
||||||
if (options.dev && isUrl(options.build.publicPath)) {
|
if (options.dev && isUrl(options.build.publicPath)) {
|
||||||
options.build.publicPath = defaultOptions.build.publicPath
|
options.build.publicPath = Options.defaults.build.publicPath
|
||||||
}
|
}
|
||||||
|
|
||||||
// If store defined, update store options to true unless explicitly disabled
|
// If store defined, update store options to true unless explicitly disabled
|
||||||
@ -52,7 +52,7 @@ export default function Options (_options) {
|
|||||||
mode = mode()
|
mode = mode()
|
||||||
}
|
}
|
||||||
if (typeof mode === 'string') {
|
if (typeof mode === 'string') {
|
||||||
mode = Modes[mode]
|
mode = Options.modes[mode]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply mode
|
// Apply mode
|
||||||
@ -61,7 +61,7 @@ export default function Options (_options) {
|
|||||||
return options
|
return options
|
||||||
}
|
}
|
||||||
|
|
||||||
const Modes = {
|
Options.modes = {
|
||||||
universal: {
|
universal: {
|
||||||
build: {
|
build: {
|
||||||
ssr: true
|
ssr: true
|
||||||
@ -88,7 +88,7 @@ const Modes = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const defaultOptions = {
|
Options.defaults = {
|
||||||
mode: 'universal',
|
mode: 'universal',
|
||||||
dev: process.env.NODE_ENV !== 'production',
|
dev: process.env.NODE_ENV !== 'production',
|
||||||
buildDir: '.nuxt',
|
buildDir: '.nuxt',
|
@ -1,13 +1,20 @@
|
|||||||
import Options from './options'
|
import { Options, Utils } from 'common'
|
||||||
import ModuleContainer from './module'
|
import Module from './module'
|
||||||
import Nuxt from './nuxt'
|
import Nuxt from './nuxt'
|
||||||
import Renderer from './renderer'
|
import Renderer from './renderer'
|
||||||
import * as Utils from 'utils'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
Options,
|
|
||||||
ModuleContainer,
|
|
||||||
Nuxt,
|
Nuxt,
|
||||||
|
Module,
|
||||||
Renderer,
|
Renderer,
|
||||||
|
Options,
|
||||||
|
Utils
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
Nuxt,
|
||||||
|
Module,
|
||||||
|
Renderer,
|
||||||
|
Options,
|
||||||
Utils
|
Utils
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import Tapable from 'tappable'
|
import Tapable from 'tappable'
|
||||||
import chalk from 'chalk'
|
import chalk from 'chalk'
|
||||||
|
import { Options } from 'common'
|
||||||
import ModuleContainer from './module'
|
import ModuleContainer from './module'
|
||||||
import Renderer from './renderer'
|
import Renderer from './renderer'
|
||||||
import Options from './options'
|
|
||||||
import Debug from 'debug'
|
import Debug from 'debug'
|
||||||
import enableDestroy from 'server-destroy'
|
import enableDestroy from 'server-destroy'
|
||||||
import Module from 'module'
|
import Module from 'module'
|
||||||
|
@ -11,9 +11,9 @@ import { join, resolve } from 'path'
|
|||||||
import fs from 'fs-extra'
|
import fs from 'fs-extra'
|
||||||
import { createBundleRenderer } from 'vue-server-renderer'
|
import { createBundleRenderer } from 'vue-server-renderer'
|
||||||
import { encodeHtml, getContext, setAnsiColors, isUrl } from 'utils'
|
import { encodeHtml, getContext, setAnsiColors, isUrl } from 'utils'
|
||||||
import { defaultOptions } from './options'
|
|
||||||
import Debug from 'debug'
|
import Debug from 'debug'
|
||||||
import connect from 'connect'
|
import connect from 'connect'
|
||||||
|
import { Options } from 'common'
|
||||||
|
|
||||||
const debug = Debug('nuxt:render')
|
const debug = Debug('nuxt:render')
|
||||||
debug.color = 4 // Force blue color
|
debug.color = 4 // Force blue color
|
||||||
@ -196,7 +196,7 @@ export default class Renderer extends Tapable {
|
|||||||
if (!this.options.dev) {
|
if (!this.options.dev) {
|
||||||
const distDir = resolve(this.options.buildDir, 'dist')
|
const distDir = resolve(this.options.buildDir, 'dist')
|
||||||
this.useMiddleware({
|
this.useMiddleware({
|
||||||
path: isUrl(this.options.build.publicPath) ? defaultOptions.build.publicPath : this.options.build.publicPath,
|
path: isUrl(this.options.build.publicPath) ? Options.defaults.build.publicPath : this.options.build.publicPath,
|
||||||
handler: serveStatic(distDir, {
|
handler: serveStatic(distDir, {
|
||||||
index: false, // Don't serve index.html template
|
index: false, // Don't serve index.html template
|
||||||
maxAge: (this.options.dev ? 0 : '1y') // 1 year in production
|
maxAge: (this.options.dev ? 0 : '1y') // 1 year in production
|
||||||
|
Loading…
Reference in New Issue
Block a user