Skip to content

Commit

Permalink
fix: ensure base ends with a slash
Browse files Browse the repository at this point in the history
  • Loading branch information
innocenzi committed Feb 25, 2021
1 parent 10bebeb commit 891aeb9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion npm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "laravel-vite",
"version": "0.0.6",
"version": "0.0.7",
"author": "Enzo Innocenzi",
"license": "MIT",
"main": "dist/index.js",
Expand Down
7 changes: 6 additions & 1 deletion npm/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 += '/'
}
Expand Down

0 comments on commit 891aeb9

Please # to comment.