Skip to content

Commit 6450b9f

Browse files
committed
Merge branch 'main' into 1.x
2 parents d3c3869 + 7abca67 commit 6450b9f

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535

3636
steps:
3737
- name: Checkout repository
38-
uses: actions/checkout@v3
38+
uses: actions/checkout@v4
3939

4040
# Initializes the CodeQL tools for scanning.
4141
- name: Initialize CodeQL

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222

2323
steps:
2424
- name: Checkout code
25-
uses: actions/checkout@v3
25+
uses: actions/checkout@v4
2626

2727
- name: Use Node.js ${{ matrix.node-version }}
2828
uses: actions/setup-node@v3

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
# Release Notes
22

3-
## [Unreleased](https://github.com/laravel/vite-plugin/compare/v0.7.8...main)
3+
## [Unreleased](https://github.com/laravel/vite-plugin/compare/v0.8.1...main)
4+
5+
## [v0.8.1](https://github.com/laravel/vite-plugin/compare/v0.8.0...v0.8.1) - 2023-09-26
6+
7+
- [0.8] Fix issue with `0.0.0.0` network resolution by [@timacdonald](https://github.com/timacdonald) in https://github.com/laravel/vite-plugin/pull/241
8+
- Upgrade vitest by [@sapphi-red](https://github.com/sapphi-red) in https://github.com/laravel/vite-plugin/pull/246
9+
10+
## [v0.8.0](https://github.com/laravel/vite-plugin/compare/v0.7.8...v0.8.0) - 2023-08-08
11+
12+
- fix: compile error following upgrade.md's vite to mix guide by [@AshboDev](https://github.com/AshboDev) in https://github.com/laravel/vite-plugin/pull/231
13+
- Support Laravel Herd by [@claudiodekker](https://github.com/claudiodekker) in https://github.com/laravel/vite-plugin/pull/233
414

515
## [v0.7.8](https://github.com/laravel/vite-plugin/compare/v0.7.7...v0.7.8) - 2023-05-24
616

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "laravel-vite-plugin",
3-
"version": "0.7.8",
3+
"version": "0.8.1",
44
"description": "Laravel plugin for Vite.",
55
"keywords": [
66
"laravel",
@@ -47,7 +47,7 @@
4747
"eslint": "^8.14.0",
4848
"typescript": "^4.6.4",
4949
"vite": "^4.0.0",
50-
"vitest": "^0.25.2"
50+
"vitest": "^0.34.4"
5151
},
5252
"peerDependencies": {
5353
"vite": "^3.0.0 || ^4.0.0"

src/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ export default function laravel(config: string|string[]|PluginConfig): [LaravelP
116116
function resolveLaravelPlugin(pluginConfig: Required<PluginConfig>): LaravelPlugin {
117117
let viteDevServerUrl: DevServerUrl
118118
let resolvedConfig: ResolvedConfig
119+
let userConfig: UserConfig
119120

120121
const defaultAliases: Record<string, string> = {
121122
'@': '/resources/js',
@@ -124,7 +125,8 @@ function resolveLaravelPlugin(pluginConfig: Required<PluginConfig>): LaravelPlug
124125
return {
125126
name: 'laravel',
126127
enforce: 'post',
127-
config: (userConfig, { command, mode }) => {
128+
config: (config, { command, mode }) => {
129+
userConfig = config
128130
const ssr = !! userConfig.build?.ssr
129131
const env = loadEnv(mode, userConfig.envDir || process.cwd(), '')
130132
const assetUrl = env.ASSET_URL ?? ''
@@ -202,7 +204,7 @@ function resolveLaravelPlugin(pluginConfig: Required<PluginConfig>): LaravelPlug
202204

203205
const isAddressInfo = (x: string|AddressInfo|null|undefined): x is AddressInfo => typeof x === 'object'
204206
if (isAddressInfo(address)) {
205-
viteDevServerUrl = resolveDevServerUrl(address, server.config)
207+
viteDevServerUrl = resolveDevServerUrl(address, server.config, userConfig)
206208
fs.writeFileSync(pluginConfig.hotFile, viteDevServerUrl)
207209

208210
setTimeout(() => {
@@ -406,16 +408,17 @@ function resolveFullReloadConfig({ refresh: config }: Required<PluginConfig>): P
406408
/**
407409
* Resolve the dev server URL from the server address and configuration.
408410
*/
409-
function resolveDevServerUrl(address: AddressInfo, config: ResolvedConfig): DevServerUrl {
411+
function resolveDevServerUrl(address: AddressInfo, config: ResolvedConfig, userConfig: UserConfig): DevServerUrl {
410412
const configHmrProtocol = typeof config.server.hmr === 'object' ? config.server.hmr.protocol : null
411413
const clientProtocol = configHmrProtocol ? (configHmrProtocol === 'wss' ? 'https' : 'http') : null
412414
const serverProtocol = config.server.https ? 'https' : 'http'
413415
const protocol = clientProtocol ?? serverProtocol
414416

415417
const configHmrHost = typeof config.server.hmr === 'object' ? config.server.hmr.host : null
416418
const configHost = typeof config.server.host === 'string' ? config.server.host : null
419+
const sailHost = process.env.LARAVEL_SAIL && ! userConfig.server?.host ? 'localhost' : null
417420
const serverAddress = isIpv6(address) ? `[${address.address}]` : address.address
418-
const host = configHmrHost ?? configHost ?? serverAddress
421+
const host = configHmrHost ?? sailHost ?? configHost ?? serverAddress
419422

420423
const configHmrClientPort = typeof config.server.hmr === 'object' ? config.server.hmr.clientPort : null
421424
const port = configHmrClientPort ?? address.port

0 commit comments

Comments
 (0)