質問編集履歴
1
ディレクトリ構造、2ファイルの内容を追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -9,6 +9,27 @@
|
|
9
9
|
ローカル環境にNode.js(Express)のサーバーを起動して開発しています。
|
10
10
|
|
11
11
|
---
|
12
|
+
ディレクトリ構造
|
13
|
+
```
|
14
|
+
***/
|
15
|
+
├─ node_modules
|
16
|
+
├─ public
|
17
|
+
│ ├─ css
|
18
|
+
│ │ ├─ common.css
|
19
|
+
│ │ └─ reset.css
|
20
|
+
│ ├─ dist
|
21
|
+
│ │ └─ bundle.js
|
22
|
+
│ └─ html
|
23
|
+
│ └─ index.html
|
24
|
+
├─ script
|
25
|
+
│ └─ hyperapp.js
|
26
|
+
├─ .babelrc
|
27
|
+
├─ .gitignore
|
28
|
+
├─ package-lock.json
|
29
|
+
├─ package.json
|
30
|
+
├─ web-server.js
|
31
|
+
└─ webpack.config.js
|
32
|
+
```
|
12
33
|
package.json
|
13
34
|
```
|
14
35
|
{
|
@@ -81,6 +102,40 @@
|
|
81
102
|
]]
|
82
103
|
}
|
83
104
|
```
|
105
|
+
web-server.js
|
106
|
+
```
|
107
|
+
const express = require('express');
|
108
|
+
const server = express();
|
109
|
+
const port = 3000;
|
110
|
+
const path = require('path');
|
111
|
+
|
112
|
+
server.set( 'view engine', 'ejs' );
|
113
|
+
server.use( '/' , express.static( __dirname+'/public' ) );
|
114
|
+
server.use( '/' , express.static( __dirname+'/public/html' ) );
|
115
|
+
server.use( '/' , express.static( __dirname+'/public/css' ) );
|
116
|
+
server.use( '/' , express.static( __dirname+'/public/dist' ) );
|
117
|
+
|
118
|
+
server.get( '/', ( request, response )=>{
|
119
|
+
response.status(200).sendfile( 'index' );
|
120
|
+
});
|
121
|
+
|
122
|
+
server.listen(port);
|
123
|
+
```
|
124
|
+
index.html
|
125
|
+
```
|
126
|
+
<!DOCTYPE html>
|
127
|
+
<html lang="ja">
|
128
|
+
<head>
|
129
|
+
<meta charset="UTF-8">
|
130
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
131
|
+
<title>***</title>
|
132
|
+
<script type="module" src="bundle.js"></script>
|
133
|
+
</head>
|
134
|
+
<body>
|
135
|
+
<main id="app"></main>
|
136
|
+
</body>
|
137
|
+
</html>
|
138
|
+
```
|
84
139
|
hyperapp.js
|
85
140
|
```
|
86
141
|
import { h, app } from "hyperapp";
|