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