From 891aeb98704e1d4eca3f04e72e3497eb647fb96b Mon Sep 17 00:00:00 2001 From: Enzo Innocenzi Date: Thu, 25 Feb 2021 20:34:45 +0100 Subject: [PATCH] fix: ensure base ends with a slash --- npm/package.json | 2 +- npm/src/index.ts | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/npm/package.json b/npm/package.json index 7da09ff..f26fd3d 100644 --- a/npm/package.json +++ b/npm/package.json @@ -1,6 +1,6 @@ { "name": "laravel-vite", - "version": "0.0.6", + "version": "0.0.7", "author": "Enzo Innocenzi", "license": "MIT", "main": "dist/index.js", diff --git a/npm/src/index.ts b/npm/src/index.ts index f5a3d9f..8213612 100644 --- a/npm/src/index.ts +++ b/npm/src/index.ts @@ -44,13 +44,18 @@ export class ViteConfiguration { dotenv.config() // Sets the base directory. - this.base = process.env.ASSET_URL ?? '/' + this.base = process.env.ASSET_URL ?? '' + + // Makes sure the base ends with a slash. + if (!this.base.endsWith('/')) + this.base += '/' // In production, we want to append the build_path. It is not needed in development, // since assets are served from the development server's root, but we're writing // generated assets in public/build_path, so build_path needs to be referenced. if (process.env.NODE_ENV?.startsWith('prod') || process.env.APP_ENV !== 'local') { this.base += artisan.build_path ?? '' + if (!this.base.endsWith('/')) this.base += '/' }