-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support customized config.server.hmr (fix #119)
- Loading branch information
Showing
12 changed files
with
157 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { killServer, preTest, viteServe } from 'vite-plugin-checker/__tests__/e2e/Sandbox/Sandbox' | ||
import { | ||
editFile, | ||
sleep, | ||
testDir, | ||
WORKER_CLEAN_TIMEOUT, | ||
} from 'vite-plugin-checker/__tests__/e2e/testUtils' | ||
import { WebSocketServer } from 'ws' | ||
|
||
import { copyCode } from '../../../scripts/jestSetupFilesAfterEnv' | ||
import { serializers } from '../../../scripts/serializers' | ||
|
||
expect.addSnapshotSerializer(serializers) | ||
|
||
beforeAll(async () => { | ||
await preTest() | ||
}) | ||
|
||
afterAll(async () => { | ||
await sleep(WORKER_CLEAN_TIMEOUT) | ||
}) | ||
|
||
describe('hmr', () => { | ||
beforeEach(async () => { | ||
await copyCode() | ||
}) | ||
|
||
afterEach(async () => { | ||
await killServer() | ||
}) | ||
|
||
it('hmr-config', async () => { | ||
const port = 4567 | ||
const path = '/custom-path' | ||
|
||
const hmrConfig = ` | ||
server: { | ||
hmr: { | ||
clientPort: ${port}, | ||
path: '${path}', | ||
}, | ||
},` | ||
|
||
editFile('vite.config.ts', (code) => code.replace('// config-edit-slot', hmrConfig)) | ||
|
||
const ws = new WebSocketServer({ | ||
port, | ||
path, | ||
}) | ||
|
||
const wsPromise = new Promise((resolve) => { | ||
ws.on('connection', function connection(ws) { | ||
resolve(undefined) | ||
}) | ||
}) | ||
|
||
await viteServe({ cwd: testDir, launchPage: true }) | ||
await wsPromise | ||
ws.close() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.