fix: fall back to default value when publicPath is falsy (#4365)

* test: let tests fail

* fix: add falsy default fallback

* fix(publicPath): force adding trailing slash

* fix: also change _publicPath
This commit is contained in:
Alexander Lichter 2018-11-20 18:12:05 +01:00 committed by Pooya Parsa
parent cebed3509f
commit 9aeeb2276e
2 changed files with 12 additions and 1 deletions

View File

@ -5,7 +5,7 @@ import defaults from 'lodash/defaults'
import pick from 'lodash/pick'
import isObject from 'lodash/isObject'
import consola from 'consola'
import { isPureObject, isUrl, guardDir, isNonEmptyString } from '@nuxt/common'
import { guardDir, isNonEmptyString, isPureObject, isUrl } from '@nuxt/common'
import { getDefaultNuxtConfig } from './config'
export function getNuxtConfig(_options) {
@ -53,7 +53,14 @@ export function getNuxtConfig(_options) {
// Apply defaults
const nuxtConfig = getDefaultNuxtConfig()
nuxtConfig.build._publicPath = nuxtConfig.build.publicPath
// Fall back to default if publicPath is falsy
if (options.build && !options.build.publicPath) {
options.build.publicPath = undefined
}
defaultsDeep(options, nuxtConfig)
// Check srcDir and generate.dir excistence
@ -111,6 +118,9 @@ export function getNuxtConfig(_options) {
options.appTemplatePath = path.resolve(options.srcDir, options.appTemplatePath)
}
options.build.publicPath = options.build.publicPath.replace(/([^/])$/, '$1/')
options.build._publicPath = options.build._publicPath.replace(/([^/])$/, '$1/')
// Ignore publicPath on dev
/* istanbul ignore if */
if (options.dev && isUrl(options.build.publicPath)) {

View File

@ -70,6 +70,7 @@ export default {
],
build: {
scopeHoisting: true,
publicPath: '',
postcss: {
preset: {
features: {