Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from Nov 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion packages/config/src/options.js
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)) {
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/basic/nuxt.config.js
Expand Up @@ -70,6 +70,7 @@ export default {
],
build: {
scopeHoisting: true,
publicPath: '',
postcss: {
preset: {
features: {
Expand Down