Skip to content

Commit

Permalink
fix: only use custom publicPath if it is not absolute
Browse files Browse the repository at this point in the history
* closes #578
  • Loading branch information
danielroe committed Jun 10, 2021
1 parent 692e350 commit d8df9af
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"rc9": "^1.2.0",
"replace-in-file": "^6.2.0",
"resolve-from": "^5.0.0",
"semver": "7.3.5"
"semver": "7.3.5",
"ufo": "^0.7.5"
},
"devDependencies": {
"@nuxt/types": "^2.15.6",
Expand Down
6 changes: 5 additions & 1 deletion src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import fs from 'fs-extra'
import resolveFrom from 'resolve-from'
import { gte, gt } from 'semver'
import { update as updaterc } from 'rc9'
import { hasProtocol } from 'ufo'

import { endStep, exec, getNuxtConfig, getNuxtConfigName, globAndPrefix, MutablePackageJson, prepareNodeModules, preparePkgForProd, readJSON, startStep, validateEntrypoint } from './utils'
import { prepareTypescriptEnvironment, compileTypescriptBuildFiles, JsonOptions } from './typescript'
Expand Down Expand Up @@ -150,7 +151,10 @@ export async function build (opts: BuildOptions & { config: NuxtBuilderConfig })

// Read options from nuxt.config.js otherwise set sensible defaults
const staticDir = (nuxtConfigFile.dir && nuxtConfigFile.dir.static) ? nuxtConfigFile.dir.static : 'static'
const publicPath = ((nuxtConfigFile.build && nuxtConfigFile.build.publicPath) ? nuxtConfigFile.build.publicPath : '/_nuxt/').replace(/^\//, '')
let publicPath = ((nuxtConfigFile.build && nuxtConfigFile.build.publicPath) ? nuxtConfigFile.build.publicPath : '/_nuxt/').replace(/^\//, '')
if (hasProtocol(publicPath)) {
publicPath = '_nuxt/'
}
const buildDir = nuxtConfigFile.buildDir ? path.relative(entrypointPath, nuxtConfigFile.buildDir) : '.nuxt'
const srcDir = nuxtConfigFile.srcDir ? path.relative(entrypointPath, nuxtConfigFile.srcDir) : '.'
const lambdaName = nuxtConfigFile.lambdaName ? nuxtConfigFile.lambdaName : 'index'
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11637,7 +11637,7 @@ ua-parser-js@^0.7.28:
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.28.tgz#8ba04e653f35ce210239c64661685bf9121dec31"
integrity sha512-6Gurc1n//gjp9eQNXjD9O3M/sMwVtN5S8Lv9bvOYBfKfDNiIIhqiyi01vMBO45u4zkDE420w/e0se7Vs+sIg+g==

ufo@^0.7.4:
ufo@^0.7.4, ufo@^0.7.5:
version "0.7.5"
resolved "https://registry.yarnpkg.com/ufo/-/ufo-0.7.5.tgz#5d5b2174747c0072edd30501994c8ac4ad2e77ea"
integrity sha512-FGG+EgguC1oz5dTE1JptPWCyj6Z9mYpwvZY8PTu9Vh/Aoy+Mj9cpeQ3gg4kyEMDbMrH+lTYiw7bomG58B8X7Kg==
Expand Down

0 comments on commit d8df9af

Please sign in to comment.