Skip to content

Commit

Permalink
feat: update default port to 5173
Browse files Browse the repository at this point in the history
  • Loading branch information
innocenzi committed Jun 1, 2022
1 parent d6abbb4 commit b349c99
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion config/vite.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
],
'dev_server' => [
'enabled' => true,
'url' => env('DEV_SERVER_URL', 'http://localhost:3000'),
'url' => env('DEV_SERVER_URL', 'http://localhost:5173'),
'ping_before_using_manifest' => true,
'ping_url' => null,
'ping_timeout' => 1,
Expand Down
10 changes: 5 additions & 5 deletions tests/Features/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

it('uses the default configuration when not specifying one', function () {
expect(vite()->getClientScriptTag())
->toEqual('<script type="module" src="http://localhost:3000/@vite/client"></script>');
->toEqual('<script type="module" src="http://localhost:5173/@vite/client"></script>');
});

it('uses the right configuration when specifying it', function () {
Expand Down Expand Up @@ -101,7 +101,7 @@
],
]);

expect(vite()->getTag('main'))->toContain('http://localhost:3000/entrypoints/multiple/main.ts');
expect(vite()->getTag('main'))->toContain('http://localhost:5173/entrypoints/multiple/main.ts');
});

it('throws when getting a tag for an entrypoint that could not be found', function () {
Expand All @@ -122,8 +122,8 @@
set_env('local');

set_vite_config('default', ['build_path' => '/should-not-be/included']);
expect(vite()->getAssetUrl('/my-custom-asset.txt'))->toContain('http://localhost:3000/my-custom-asset.txt');
expect(vite()->getAssetUrl('without-leading-slash.txt'))->toContain('http://localhost:3000/without-leading-slash.txt');
expect(vite()->getAssetUrl('/my-custom-asset.txt'))->toContain('http://localhost:5173/my-custom-asset.txt');
expect(vite()->getAssetUrl('without-leading-slash.txt'))->toContain('http://localhost:5173/without-leading-slash.txt');
});

it('returns a valid asset URL in production', function () {
Expand Down Expand Up @@ -204,7 +204,7 @@
],
]);

expect(vite()->getEntryUrl('main'))->toContain('http://localhost:3000/entrypoints/multiple/main.ts');
expect(vite()->getEntryUrl('main'))->toContain('http://localhost:5173/entrypoints/multiple/main.ts');
});

it('returns an entrypoint URL in production', function () {
Expand Down
8 changes: 4 additions & 4 deletions tests/Features/DevelopmentServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
with_dev_server();
set_env('local');
expect(vite()->getClientScriptTag())
->toBe('<script type="module" src="http://localhost:3000/@vite/client"></script>');
->toBe('<script type="module" src="http://localhost:5173/@vite/client"></script>');
});

it('generates the Vite client script tag with the other tags', function () {
Expand All @@ -67,7 +67,7 @@
]);

expect(vite()->getTags())
->toContain('<script type="module" src="http://localhost:3000/@vite/client"></script>')
->toContain('<script type="module" src="http://localhost:3000/entrypoints/multiple/main.ts"></script>')
->toContain('<script type="module" src="http://localhost:3000/entrypoints/multiple/secondary.ts"></script>');
->toContain('<script type="module" src="http://localhost:5173/@vite/client"></script>')
->toContain('<script type="module" src="http://localhost:5173/entrypoints/multiple/main.ts"></script>')
->toContain('<script type="module" src="http://localhost:5173/entrypoints/multiple/secondary.ts"></script>');
});
12 changes: 6 additions & 6 deletions tests/Features/TagGeneratorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
]);

expect(vite()->getTags())
->toContain('<script type="module" src="http://localhost:3000/@vite/client" crossorigin></script>')
->toContain('<script type="module" src="http://localhost:3000/entrypoints/multiple-with-css/main.ts" crossorigin></script>')
->toContain('<link rel="stylesheet" href="http://localhost:3000/entrypoints/multiple-with-css/style.css" crossorigin />');
->toContain('<script type="module" src="http://localhost:5173/@vite/client" crossorigin></script>')
->toContain('<script type="module" src="http://localhost:5173/entrypoints/multiple-with-css/main.ts" crossorigin></script>')
->toContain('<link rel="stylesheet" href="http://localhost:5173/entrypoints/multiple-with-css/style.css" crossorigin />');
});

it('respects TagGenerator callback overrides in development', function () {
Expand All @@ -57,9 +57,9 @@
]);

expect(vite()->getTags())
->toContain('<script type="module" src="http://localhost:3000/@vite/client" crossorigin="anonymous"></script>')
->toContain('<script type="module" src="http://localhost:3000/entrypoints/multiple-with-css/main.ts" crossorigin="anonymous"></script>')
->toContain('<link rel="stylesheet" href="http://localhost:3000/entrypoints/multiple-with-css/style.css" crossorigin="anonymous" />');
->toContain('<script type="module" src="http://localhost:5173/@vite/client" crossorigin="anonymous"></script>')
->toContain('<script type="module" src="http://localhost:5173/entrypoints/multiple-with-css/main.ts" crossorigin="anonymous"></script>')
->toContain('<link rel="stylesheet" href="http://localhost:5173/entrypoints/multiple-with-css/style.css" crossorigin="anonymous" />');

Vite::makeScriptTagsUsing();
Vite::makeStyleTagsUsing();
Expand Down
6 changes: 3 additions & 3 deletions vite-plugin-laravel/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const config = (options: Options = {}): Plugin => {
debug('Base URL:', base || '<empty>')

// Parses dev url
const { protocol, hostname, port } = new URL(serverConfig.dev_server.url || 'http://localhost:3000')
const { protocol, hostname, port } = new URL(serverConfig.dev_server.url || 'http://localhost:5173')
const { key, cert } = findCertificates(serverConfig, env, env.APP_URL)
const usesHttps = key && cert && protocol === 'https:'
debug('Uses HTTPS:', usesHttps, { key, cert, protocol, hostname, port })
Expand Down Expand Up @@ -91,12 +91,12 @@ export const config = (options: Options = {}): Plugin => {
https: usesHttps
? { maxVersion: 'TLSv1.2' as const, key, cert }
: protocol === 'https:',
port: port ? Number(port) : 3000,
port: port ? Number(port) : 5173,
strictPort: !process.argv.includes('--no-strict-port'),
origin: `${protocol}//${hostname}:${port}`,
hmr: {
host: hostname,
port: Number(port) || 3000,
port: Number(port) || 5173,
},
},
build: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ exports[`reads config from the given option object 1`] = `
},
"build_path": "build",
"dev_server": {
"url": "http://localhost:3000",
"url": "http://localhost:5173",
},
"entrypoints": {
"paths": "resources/scripts/js",
Expand Down
2 changes: 1 addition & 1 deletion vite-plugin-laravel/tests/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ it('reads config from the given option object', () => {
config: {
aliases: { '@': 'resources' },
build_path: 'build',
dev_server: { url: 'http://localhost:3000' },
dev_server: { url: 'http://localhost:5173' },
entrypoints: { paths: 'resources/scripts/js' },
},
}, process.env)
Expand Down
2 changes: 1 addition & 1 deletion vite-plugin-laravel/tests/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ it('runs the plugin as expected', async() => {
config: {
aliases: { '@': 'vite-plugin-laravel/tests/__fixtures__/resources' },
build_path: 'build',
dev_server: { url: 'http://localhost:3000' },
dev_server: { url: 'http://localhost:5173' },
entrypoints: { paths: path.resolve(__dirname, './__fixtures__/resources/scripts/app.ts') },
},
}),
Expand Down

0 comments on commit b349c99

Please # to comment.