Skip to content

Commit 98998b7

Browse files
cyokodogcyokodog
authored andcommitted
第3回デモ追加
1 parent 5f19cb3 commit 98998b7

19 files changed

+1988
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules
22
*/dev/dist
33
*/public/scripts/*.css
44

5+
*.module.css.d.ts

02/dev/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,10 @@
99
<body>
1010
<div id="counterWidget"></div>
1111
<script src="dist/bundle.js"></script>
12+
<script>
13+
new EventSource('/esbuild').addEventListener('change', () =>
14+
location.reload()
15+
);
16+
</script>
1217
</body>
1318
</html>

02/src/App.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const App = () => {
77
appDom.classList.add(styles.App);
88
appDom.appendChild(
99
CountButton({
10-
count: 0,
10+
count,
1111
onClick: (event: Event) => {
1212
count++;
1313
(event.target as HTMLButtonElement).textContent = count.toString();

03/build/dev.mjs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import esbuild from 'esbuild';
2+
3+
try {
4+
const ctx = await esbuild.context({
5+
logLevel: 'info',
6+
entryPoints: {
7+
bundle: './src/index.ts',
8+
},
9+
bundle: true,
10+
platform: 'browser',
11+
outdir: 'dev/dist',
12+
sourcemap: true,
13+
});
14+
await ctx.watch();
15+
await ctx.serve({ servedir: './dev' });
16+
} catch (e) {
17+
console.error(e);
18+
process.exit(1);
19+
}

03/build/prod.mjs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import esbuild from 'esbuild';
2+
import cssModulesPlugin from 'esbuild-css-modules-plugin';
3+
4+
try {
5+
await esbuild.build({
6+
logLevel: 'info',
7+
entryPoints: {
8+
bundle: './src/index.ts',
9+
},
10+
bundle: true,
11+
platform: 'browser',
12+
outdir: 'public/dist',
13+
minify: true,
14+
metafile: true,
15+
plugins: [
16+
cssModulesPlugin({
17+
localsConvention: 'camelCase',
18+
inject: true,
19+
pattern: '[name]__[hash]__[local]',
20+
}),
21+
],
22+
});
23+
} catch (e) {
24+
console.error(e);
25+
process.exit(1);
26+
}

03/dev/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="ja">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Demo</title>
7+
<link rel="stylesheet" href="dist/bundle.css" />
8+
</head>
9+
<body>
10+
<div id="counterWidget"></div>
11+
<script src="dist/bundle.js"></script>
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)