mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-30 15:22:39 +00:00
refactor more into defaults
This commit is contained in:
parent
8691e21efb
commit
3747e3cc36
@ -9,10 +9,9 @@ import webpackDevMiddleware from 'webpack-dev-middleware'
|
||||
import webpackHotMiddleware from 'webpack-hot-middleware'
|
||||
import { join, resolve, basename, dirname } from 'path'
|
||||
import Tapable from 'tappable'
|
||||
import { isUrl, r, wp, createRoutes } from './utils'
|
||||
import { r, wp, createRoutes } from './utils'
|
||||
import clientWebpackConfig from './webpack/client.config.js'
|
||||
import serverWebpackConfig from './webpack/server.config.js'
|
||||
import defaults from './defaults'
|
||||
import MFS from 'memory-fs'
|
||||
|
||||
const debug = require('debug')('nuxt:build')
|
||||
@ -70,16 +69,6 @@ export default class Builder extends Tapable {
|
||||
}
|
||||
_.defaultsDeep(this.options.build, extraDefaults)
|
||||
|
||||
/* istanbul ignore if */
|
||||
if (this.options.dev && isUrl(this.options.build.publicPath)) {
|
||||
this.options.build.publicPath = defaults.build.publicPath
|
||||
}
|
||||
|
||||
// If store defined, update store options to true unless explicitly disabled
|
||||
if (this.options.store !== false && fs.existsSync(join(this.options.srcDir, 'store'))) {
|
||||
this.options.store = true
|
||||
}
|
||||
|
||||
// Mute stats on dev
|
||||
this.webpackStats = this.options.dev ? '' : {
|
||||
chunks: false,
|
||||
|
@ -1,6 +1,7 @@
|
||||
import _ from 'lodash'
|
||||
import { join, resolve } from 'path'
|
||||
import { existsSync } from 'fs'
|
||||
import { isUrl } from './utils'
|
||||
|
||||
export default function defaults (_options) {
|
||||
// Clone options to prevent unwanted side-effects
|
||||
@ -34,6 +35,16 @@ export default function defaults (_options) {
|
||||
options.appTemplatePath = join(options.srcDir, 'app.html')
|
||||
}
|
||||
|
||||
// Ignore publicPath on dev
|
||||
if (options.dev && isUrl(options.build.publicPath)) {
|
||||
options.build.publicPath = defaultOptions.build.publicPath
|
||||
}
|
||||
|
||||
// If store defined, update store options to true unless explicitly disabled
|
||||
if (options.store !== false && existsSync(join(options.srcDir, 'store'))) {
|
||||
this.options.store = true
|
||||
}
|
||||
|
||||
return options
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user