Skip to content

Commit a1703f6

Browse files
committed
fix(build): use correct resolution for router base
1 parent 89f50c8 commit a1703f6

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

lib/module.js

+8-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/module.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ const laravelModule: Module<Options> = function(_moduleOptions) {
256256
: [outputDir === publicDir ? 'spa.html' : 'index.html', outputDir]
257257

258258
// update nuxt router base if necessary
259-
const outputUrl = outputDir.replace(publicDir, '')
259+
const outputUrl = destDir.replace(publicDir, '')
260260
if (
261261
outputUrl &&
262262
(!this.options.router || this.options.router.base !== outputUrl)
@@ -291,14 +291,14 @@ const laravelModule: Module<Options> = function(_moduleOptions) {
291291
) {
292292
const envPath = path.join(laravelRoot, '.env')
293293
const envInput = fs.readFileSync(envPath).toString()
294-
const envOutput = `${EOL}# Added by 'nuxt-laravel' module${EOL}${nuxtOutputEnv}=${path.join(
295-
destDir,
296-
fileName
297-
)}`
294+
const envOutputPrefix = `${EOL}# Added by 'nuxt-laravel' module${EOL}${nuxtOutputEnv}`
295+
const envOutput = `${envOutputPrefix}=${path.join(destDir, fileName)}`
298296

299297
fs.writeFileSync(
300298
envPath,
301-
envInput.includes(nuxtOutputEnv)
299+
envInput.includes(envOutputPrefix)
300+
? envInput.replace(new RegExp(`${envOutputPrefix}.*`), envOutput)
301+
: envInput.includes(nuxtOutputEnv)
302302
? envInput.replace(new RegExp(`${nuxtOutputEnv}.*`), envOutput)
303303
: envInput.concat(envOutput)
304304
)

0 commit comments

Comments
 (0)