Skip to content

Commit 9daa533

Browse files
feat: live reload on dev environment
1 parent cbf169d commit 9daa533

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

esbuild.config.dev.mjs

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const ctx = await esbuild.context({
77
bundle: true,
88
outdir: 'build',
99
treeShaking: true,
10+
logLevel: 'info',
1011
plugins: [
1112
cssModulesPlugin({
1213
v2: true,
@@ -22,11 +23,8 @@ fs.copyFile('./public/index.html', './build/index.html', (err) => {
2223
})
2324

2425
await ctx.watch()
25-
26-
const { port } = await ctx.serve({
26+
await ctx.serve({
2727
servedir: 'build',
2828
port: 3000,
2929
host: 'localhost',
3030
})
31-
32-
console.log(`\n\n# Live Server: localhost:${port}`)

public/index.html

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
99
<title>Dev - React Tooltip</title>
1010
<link rel="stylesheet" href="/index-dev.css" />
11+
<script>
12+
new EventSource('/esbuild').addEventListener('change', () => location.reload())
13+
</script>
1114
</head>
1215
<body>
1316
<noscript>You need to enable JavaScript to run this app. Please enable JavaScript 😭</noscript>

0 commit comments

Comments
 (0)