mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
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:
parent
27e79be285
commit
e0537d54be
@ -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)) {
|
||||
|
1
test/fixtures/basic/nuxt.config.js
vendored
1
test/fixtures/basic/nuxt.config.js
vendored
@ -70,6 +70,7 @@ export default {
|
||||
],
|
||||
build: {
|
||||
scopeHoisting: true,
|
||||
publicPath: '',
|
||||
postcss: {
|
||||
preset: {
|
||||
features: {
|
||||
|
Loading…
Reference in New Issue
Block a user