質問編集履歴
2
webpack.config.js更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -46,14 +46,114 @@
|
|
46
46
|
|
47
47
|
const path = require('path');
|
48
48
|
|
49
|
+
const globule = require('globule');
|
50
|
+
|
49
|
-
const {
|
51
|
+
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
|
50
52
|
|
51
53
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
52
54
|
|
53
55
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
54
56
|
|
57
|
+
const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin');
|
58
|
+
|
55
59
|
const TerserPlugin = require("terser-webpack-plugin");
|
56
60
|
|
61
|
+
const CopyPlugin = require("copy-webpack-plugin");
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
const assignPlugins = (env_mode) => {
|
66
|
+
|
67
|
+
const srcFiles = globule.find(['**/*.ejs', '!**/_*.ejs'], {cwd: `${__dirname}/src/ejs`});
|
68
|
+
|
69
|
+
const entriesList = {};
|
70
|
+
|
71
|
+
const assignObject = {plugins: [
|
72
|
+
|
73
|
+
new CleanWebpackPlugin({
|
74
|
+
|
75
|
+
cleanOnceBeforeBuildPatterns: [
|
76
|
+
|
77
|
+
'assets/stylesheet',
|
78
|
+
|
79
|
+
'assets/javascript',
|
80
|
+
|
81
|
+
]
|
82
|
+
|
83
|
+
}),
|
84
|
+
|
85
|
+
new MiniCssExtractPlugin({
|
86
|
+
|
87
|
+
filename: env_mode
|
88
|
+
|
89
|
+
? 'assets/stylesheet/bundle.css'
|
90
|
+
|
91
|
+
: 'assets/stylesheet/bundle.[contenthash].css',
|
92
|
+
|
93
|
+
}),
|
94
|
+
|
95
|
+
new HtmlWebpackHarddiskPlugin({
|
96
|
+
|
97
|
+
alwaysWriteToDisk: true
|
98
|
+
|
99
|
+
}),
|
100
|
+
|
101
|
+
new CopyPlugin({
|
102
|
+
|
103
|
+
patterns: [
|
104
|
+
|
105
|
+
{from: "src/images/", to: "assets/images/"}
|
106
|
+
|
107
|
+
]
|
108
|
+
|
109
|
+
})
|
110
|
+
|
111
|
+
]};
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
for(const ejsFileName of srcFiles) {
|
116
|
+
|
117
|
+
const htmlFileName = ejsFileName.replace(new RegExp(`.ejs`, 'i'), `.html`);
|
118
|
+
|
119
|
+
entriesList[htmlFileName] = `${__dirname}/src/ejs/${ejsFileName}`;
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
for(const [htmlFileName, ejsFileName] of Object.entries(entriesList)) {
|
126
|
+
|
127
|
+
assignObject.plugins.push(new HtmlWebpackPlugin({
|
128
|
+
|
129
|
+
filename : htmlFileName,
|
130
|
+
|
131
|
+
template : ejsFileName,
|
132
|
+
|
133
|
+
inject: 'body',
|
134
|
+
|
135
|
+
minify: env_mode ?
|
136
|
+
|
137
|
+
false :
|
138
|
+
|
139
|
+
{
|
140
|
+
|
141
|
+
collapseWhitespace: false,
|
142
|
+
|
143
|
+
removeComments: true,
|
144
|
+
|
145
|
+
},
|
146
|
+
|
147
|
+
}));
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
return assignObject;
|
154
|
+
|
155
|
+
};
|
156
|
+
|
57
157
|
|
58
158
|
|
59
159
|
module.exports = (env, argv) => {
|
@@ -62,271 +162,265 @@
|
|
62
162
|
|
63
163
|
|
64
164
|
|
65
|
-
return
|
165
|
+
return [
|
166
|
+
|
66
|
-
|
167
|
+
Object.assign({
|
168
|
+
|
67
|
-
entry: './src/js/main',
|
169
|
+
entry: './src/js/main',
|
68
|
-
|
170
|
+
|
69
|
-
output: {
|
171
|
+
output: {
|
70
|
-
|
172
|
+
|
71
|
-
path: path.join(__dirname, 'public'),
|
173
|
+
path: path.join(__dirname, 'public'),
|
72
|
-
|
174
|
+
|
73
|
-
filename: is_DEVELOP
|
175
|
+
filename: is_DEVELOP
|
74
|
-
|
176
|
+
|
75
|
-
? 'assets/javascript/bundle.js'
|
177
|
+
? 'assets/javascript/bundle.js'
|
76
|
-
|
178
|
+
|
77
|
-
: 'assets/javascript/bundle.[contenthash].js',
|
179
|
+
: 'assets/javascript/bundle.[contenthash].js',
|
78
|
-
|
180
|
+
|
79
|
-
},
|
181
|
+
},
|
80
|
-
|
182
|
+
|
81
|
-
devtool: is_DEVELOP ? 'source-map' : 'eval',
|
183
|
+
devtool: is_DEVELOP ? 'source-map' : 'eval',
|
82
|
-
|
184
|
+
|
83
|
-
watchOptions: {
|
185
|
+
watchOptions: {
|
84
|
-
|
186
|
+
|
85
|
-
ignored: /node_modules/
|
187
|
+
ignored: /node_modules/
|
86
|
-
|
188
|
+
|
87
|
-
},
|
189
|
+
},
|
190
|
+
|
88
|
-
|
191
|
+
resolve: {
|
192
|
+
|
193
|
+
extensions: ['.js', '.ts'],
|
194
|
+
|
195
|
+
},
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
optimization: {
|
200
|
+
|
201
|
+
minimize: is_DEVELOP ? false : true,
|
202
|
+
|
89
|
-
|
203
|
+
minimizer: [
|
90
|
-
|
204
|
+
|
91
|
-
new
|
205
|
+
new TerserPlugin({
|
92
|
-
|
206
|
+
|
93
|
-
|
207
|
+
terserOptions: {
|
94
|
-
|
208
|
+
|
95
|
-
|
209
|
+
ecma: 2020,
|
210
|
+
|
96
|
-
|
211
|
+
}
|
212
|
+
|
97
|
-
|
213
|
+
})
|
98
214
|
|
99
215
|
]
|
100
216
|
|
101
|
-
}
|
217
|
+
},
|
102
|
-
|
103
|
-
|
218
|
+
|
104
|
-
|
219
|
+
|
220
|
+
|
105
|
-
|
221
|
+
module: {
|
106
|
-
|
107
|
-
|
222
|
+
|
108
|
-
|
109
|
-
: 'assets/stylesheet/bundle.[contenthash].css',
|
110
|
-
|
111
|
-
}),
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
new HtmlWebpackPlugin({
|
116
|
-
|
117
|
-
filename: 'index.html',
|
118
|
-
|
119
|
-
template: 'src/ejs/index.ejs',
|
120
|
-
|
121
|
-
inject: 'body',
|
122
|
-
|
123
|
-
minify: is_DEVELOP ?
|
124
|
-
|
125
|
-
|
223
|
+
rules: [
|
126
224
|
|
127
225
|
{
|
128
226
|
|
129
|
-
collapseWhitespace: false,
|
130
|
-
|
131
|
-
|
227
|
+
test: /.ejs$/,
|
228
|
+
|
229
|
+
use: 'ejs-compiled-loader',
|
132
230
|
|
133
231
|
},
|
134
232
|
|
135
|
-
}),
|
136
|
-
|
137
|
-
new HtmlWebpackPlugin({
|
138
|
-
|
139
|
-
filename: 'about/index.html',
|
140
|
-
|
141
|
-
template: 'src/ejs/about/index.ejs',
|
142
|
-
|
143
|
-
inject: 'body',
|
144
|
-
|
145
|
-
minify: is_DEVELOP ?
|
146
|
-
|
147
|
-
false :
|
148
|
-
|
149
233
|
{
|
150
234
|
|
235
|
+
test: /.scss$/,
|
236
|
+
|
237
|
+
use: [
|
238
|
+
|
151
|
-
|
239
|
+
MiniCssExtractPlugin.loader,
|
240
|
+
|
152
|
-
|
241
|
+
{
|
242
|
+
|
243
|
+
loader: 'css-loader',
|
244
|
+
|
245
|
+
options: {
|
246
|
+
|
247
|
+
url: false,
|
248
|
+
|
153
|
-
re
|
249
|
+
sourceMap: true,
|
250
|
+
|
251
|
+
},
|
252
|
+
|
253
|
+
},
|
254
|
+
|
255
|
+
{
|
256
|
+
|
257
|
+
loader: 'postcss-loader',
|
258
|
+
|
259
|
+
options: {
|
260
|
+
|
261
|
+
postcssOptions: {
|
262
|
+
|
263
|
+
plugins: [
|
264
|
+
|
265
|
+
[
|
266
|
+
|
267
|
+
require('autoprefixer')({grid: true}),
|
268
|
+
|
269
|
+
],
|
270
|
+
|
271
|
+
],
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
}
|
276
|
+
|
277
|
+
},
|
278
|
+
|
279
|
+
{
|
280
|
+
|
281
|
+
loader: 'sass-loader',
|
282
|
+
|
283
|
+
options: {
|
284
|
+
|
285
|
+
implementation: require('sass'),
|
286
|
+
|
287
|
+
},
|
288
|
+
|
289
|
+
},
|
290
|
+
|
291
|
+
]
|
154
292
|
|
155
293
|
},
|
156
294
|
|
157
|
-
}),
|
158
|
-
|
159
|
-
|
295
|
+
{
|
160
|
-
|
161
|
-
|
296
|
+
|
162
|
-
|
163
|
-
|
297
|
+
test: /.js$/,
|
298
|
+
|
164
|
-
|
299
|
+
exclude: /node_modules/,
|
300
|
+
|
301
|
+
use: [
|
302
|
+
|
303
|
+
{
|
304
|
+
|
305
|
+
loader: 'babel-loader',
|
306
|
+
|
307
|
+
options: {
|
308
|
+
|
309
|
+
presets: ['@babel/preset-env', '@babel/preset-react'],
|
310
|
+
|
311
|
+
plugins: ['@babel/plugin-transform-runtime'],
|
312
|
+
|
165
|
-
},
|
313
|
+
},
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
optimization: {
|
170
|
-
|
171
|
-
minimize: is_DEVELOP ?
|
172
|
-
|
173
|
-
false :
|
174
|
-
|
175
|
-
true,
|
176
|
-
|
177
|
-
minimizer: [
|
178
|
-
|
179
|
-
new TerserPlugin({
|
180
|
-
|
181
|
-
terserOptions: {
|
182
|
-
|
183
|
-
ecma: 2020,
|
184
|
-
|
185
|
-
}
|
186
|
-
|
187
|
-
})
|
188
|
-
|
189
|
-
]
|
190
|
-
|
191
|
-
},
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
module: {
|
196
|
-
|
197
|
-
rules: [
|
198
|
-
|
199
|
-
{
|
200
|
-
|
201
|
-
test: /.ejs$/,
|
202
|
-
|
203
|
-
use: 'ejs-compiled-loader',
|
204
|
-
|
205
|
-
},
|
206
|
-
|
207
|
-
{
|
208
|
-
|
209
|
-
test: /.scss$/,
|
210
|
-
|
211
|
-
use: [
|
212
|
-
|
213
|
-
MiniCssExtractPlugin.loader,
|
214
|
-
|
215
|
-
{
|
216
|
-
|
217
|
-
loader: 'css-loader',
|
218
|
-
|
219
|
-
options: {
|
220
|
-
|
221
|
-
url: false,
|
222
|
-
|
223
|
-
sourceMap: true,
|
224
314
|
|
225
315
|
},
|
226
316
|
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
317
|
+
],
|
318
|
+
|
319
|
+
},
|
320
|
+
|
321
|
+
{
|
322
|
+
|
323
|
+
enforce: 'pre',
|
324
|
+
|
325
|
+
test: /.js$/,
|
326
|
+
|
327
|
+
exclude: /node_modules/,
|
328
|
+
|
329
|
+
loader: 'eslint-loader',
|
330
|
+
|
331
|
+
},
|
332
|
+
|
333
|
+
],
|
334
|
+
|
335
|
+
},
|
336
|
+
|
337
|
+
devServer: {
|
338
|
+
|
339
|
+
contentBase: path.resolve(__dirname, 'public'),
|
340
|
+
|
341
|
+
port: 8080,
|
342
|
+
|
343
|
+
},
|
344
|
+
|
345
|
+
stats: {
|
346
|
+
|
347
|
+
children: true
|
348
|
+
|
349
|
+
},
|
350
|
+
|
351
|
+
target: is_DEVELOP ?
|
352
|
+
|
353
|
+
"web" :
|
354
|
+
|
355
|
+
["web", "es5"]
|
356
|
+
|
357
|
+
}, assignPlugins(is_DEVELOP))
|
358
|
+
|
359
|
+
]
|
360
|
+
|
361
|
+
}
|
362
|
+
|
363
|
+
```
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
###### index.ejs
|
368
|
+
|
369
|
+
index.ejsでは以下のようにテンプレートファイルをincludeしています。
|
370
|
+
|
371
|
+
```ejs
|
372
|
+
|
373
|
+
<% var title = "TOP"; var description = "description"; %>
|
374
|
+
|
375
|
+
<% var path = '/assets/images/'; %>
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
<% include ./template/_head %>
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
<% include ./template/_header %>
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
<main class="l-main">
|
388
|
+
|
389
|
+
...
|
390
|
+
|
391
|
+
</main>
|
392
|
+
|
393
|
+
<!-- l-footer -->
|
394
|
+
|
395
|
+
<% include ./template/_footer %>
|
396
|
+
|
397
|
+
```
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
###### package.json
|
402
|
+
|
403
|
+
```
|
404
|
+
|
405
|
+
{
|
406
|
+
|
407
|
+
...
|
408
|
+
|
409
|
+
"scripts": {
|
410
|
+
|
411
|
+
"start": "webpack serve --mode=development",
|
412
|
+
|
413
|
+
"dev": "webpack --mode=development",
|
414
|
+
|
415
|
+
"prod": "webpack --mode=production",
|
416
|
+
|
417
|
+
"watch": "webpack -w --mode=development"
|
418
|
+
|
419
|
+
},
|
420
|
+
|
421
|
+
"devDependencies": {
|
422
|
+
|
423
|
+
...
|
330
424
|
|
331
425
|
}
|
332
426
|
|
@@ -336,176 +430,110 @@
|
|
336
430
|
|
337
431
|
|
338
432
|
|
433
|
+
|
434
|
+
|
339
|
-
######
|
435
|
+
###### devserver起動時のログ
|
340
|
-
|
341
|
-
index.ejsでは以下のようにテンプレートファイルをincludeしています。
|
342
|
-
|
343
|
-
```ejs
|
344
|
-
|
345
|
-
<% var title = "TOP"; var description = "description"; %>
|
346
|
-
|
347
|
-
<% var path = '/assets/images/'; %>
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
<% include ./template/_head %>
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
<% include ./template/_header %>
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
<main class="l-main">
|
360
|
-
|
361
|
-
...
|
362
|
-
|
363
|
-
</main>
|
364
|
-
|
365
|
-
<!-- l-footer -->
|
366
|
-
|
367
|
-
<% include ./template/_footer %>
|
368
436
|
|
369
437
|
```
|
370
438
|
|
371
|
-
|
372
|
-
|
373
|
-
|
439
|
+
$ yarn start
|
440
|
+
|
441
|
+
yarn run v1.22.10
|
442
|
+
|
443
|
+
$ webpack serve --mode=development
|
444
|
+
|
445
|
+
ℹ 「wds」: Project is running at http://localhost:8080/
|
446
|
+
|
447
|
+
ℹ 「wds」: webpack output is served from /
|
448
|
+
|
449
|
+
ℹ 「wds」: Content not from webpack is served from /path/to/dir/public
|
450
|
+
|
451
|
+
(node:44401) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at /path/to/dir/node_modules/css-loader/node_modules/postcss/package.json.
|
452
|
+
|
453
|
+
Update this package.json to use a subpath pattern like "./*".
|
454
|
+
|
455
|
+
(Use `node --trace-deprecation ...` to show where the warning was created)
|
456
|
+
|
457
|
+
ℹ 「wdm」: assets by path assets/ 392 KiB
|
458
|
+
|
459
|
+
asset assets/javascript/bundle.js 387 KiB [emitted] (name: main) 1 related asset
|
460
|
+
|
461
|
+
asset assets/stylesheet/bundle.css 5.45 KiB [emitted] (name: main) 1 related asset
|
462
|
+
|
463
|
+
asset index.html 4.98 KiB [emitted]
|
464
|
+
|
465
|
+
asset about/index.html 1.75 KiB [emitted]
|
466
|
+
|
467
|
+
Entrypoint main 392 KiB (449 KiB) = assets/stylesheet/bundle.css 5.45 KiB assets/javascript/bundle.js 387 KiB 2 auxiliary assets
|
468
|
+
|
469
|
+
runtime modules 1.25 KiB 6 modules
|
470
|
+
|
471
|
+
modules by path ./node_modules/ 361 KiB
|
472
|
+
|
473
|
+
modules by path ./node_modules/webpack-dev-server/ 21.2 KiB 12 modules
|
474
|
+
|
475
|
+
modules by path ./node_modules/html-entities/lib/.js 61 KiB 5 modules
|
476
|
+
|
477
|
+
modules by path ./node_modules/@babel/runtime/ 1.55 KiB 4 modules
|
478
|
+
|
479
|
+
modules by path ./node_modules/webpack/hot/ 1.58 KiB 3 modules
|
480
|
+
|
481
|
+
modules by path ./node_modules/querystring/.js 4.51 KiB 3 modules
|
482
|
+
|
483
|
+
modules by path ./node_modules/url/.js 23.1 KiB 2 modules
|
484
|
+
|
485
|
+
modules by path ./src/ 4.31 KiB (javascript) 5.42 KiB (css/mini-extract)
|
486
|
+
|
487
|
+
modules by path ./src/js/ 4.27 KiB 3 modules
|
488
|
+
|
489
|
+
modules by path ./src/scss/ *.scss 50 bytes (javascript) 5.42 KiB (css/mini-extract)
|
490
|
+
|
491
|
+
./src/scss/app.scss 50 bytes [built] [code generated]
|
492
|
+
|
493
|
+
css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[1].use[2]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[1].use[3]!./src/scss/app.scss 5.42 KiB [code generated]
|
494
|
+
|
495
|
+
Entrypoint HtmlWebpackPlugin_0-0 =
|
496
|
+
|
497
|
+
Entrypoint HtmlWebpackPlugin_1-0 =
|
498
|
+
|
499
|
+
runtime modules 1.43 KiB 8 modules
|
500
|
+
|
501
|
+
cacheable modules 9.14 KiB
|
502
|
+
|
503
|
+
data:text/javascript,__webpack_public_path__ = __webpack_base_uri__ = htmlWebpackPluginPublicPath; 77 bytes [built] [code generated]
|
504
|
+
|
505
|
+
./node_modules/html-webpack-plugin/lib/loader.js!./src/ejs/index.ejs 6.22 KiB [built] [code generated]
|
506
|
+
|
507
|
+
./node_modules/html-webpack-plugin/lib/loader.js!./src/ejs/about/index.ejs 2.85 KiB [built] [code generated]
|
508
|
+
|
509
|
+
|
510
|
+
|
511
|
+
Child HtmlWebpackCompiler compiled successfully
|
512
|
+
|
513
|
+
|
514
|
+
|
515
|
+
Entrypoint child =
|
516
|
+
|
517
|
+
runtime modules 937 bytes 4 modules
|
518
|
+
|
519
|
+
cacheable modules 21 KiB
|
520
|
+
|
521
|
+
./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[1].use[2]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[1].use[3]!./src/scss/app.scss 17.3 KiB [built] [code generated]
|
522
|
+
|
523
|
+
./node_modules/css-loader/dist/runtime/cssWithMappingToString.js 2.21 KiB [built] [code generated]
|
524
|
+
|
525
|
+
./node_modules/css-loader/dist/runtime/api.js 1.57 KiB [built] [code generated]
|
526
|
+
|
527
|
+
|
528
|
+
|
529
|
+
Child mini-css-extract-plugin /path/to/dir/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].use[1]!/path/to/dir/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[1].use[2]!/path/to/dir/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[1].use[3]!/path/to/dir/src/scss/app.scss compiled successfully
|
530
|
+
|
531
|
+
webpack 5.28.0 compiled successfully in 1357 ms
|
532
|
+
|
533
|
+
ℹ 「wdm」: Compiled successfully.
|
374
534
|
|
375
535
|
```
|
376
536
|
|
377
|
-
{
|
378
|
-
|
379
|
-
...
|
380
|
-
|
381
|
-
"scripts": {
|
382
|
-
|
383
|
-
"start": "webpack serve --mode=development",
|
384
|
-
|
385
|
-
"dev": "webpack --mode=development",
|
386
|
-
|
387
|
-
"prod": "webpack --mode=production",
|
388
|
-
|
389
|
-
"watch": "webpack -w --mode=development"
|
390
|
-
|
391
|
-
},
|
392
|
-
|
393
|
-
"devDependencies": {
|
394
|
-
|
395
|
-
...
|
396
|
-
|
397
|
-
}
|
398
|
-
|
399
|
-
}
|
400
|
-
|
401
|
-
```
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
###### devserver起動時のログ
|
408
|
-
|
409
|
-
```
|
410
|
-
|
411
|
-
$ yarn start
|
412
|
-
|
413
|
-
yarn run v1.22.10
|
414
|
-
|
415
|
-
$ webpack serve --mode=development
|
416
|
-
|
417
|
-
ℹ 「wds」: Project is running at http://localhost:8080/
|
418
|
-
|
419
|
-
ℹ 「wds」: webpack output is served from /
|
420
|
-
|
421
|
-
ℹ 「wds」: Content not from webpack is served from /path/to/dir/public
|
422
|
-
|
423
|
-
(node:44401) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at /path/to/dir/node_modules/css-loader/node_modules/postcss/package.json.
|
424
|
-
|
425
|
-
Update this package.json to use a subpath pattern like "./*".
|
426
|
-
|
427
|
-
(Use `node --trace-deprecation ...` to show where the warning was created)
|
428
|
-
|
429
|
-
ℹ 「wdm」: assets by path assets/ 392 KiB
|
430
|
-
|
431
|
-
asset assets/javascript/bundle.js 387 KiB [emitted] (name: main) 1 related asset
|
432
|
-
|
433
|
-
asset assets/stylesheet/bundle.css 5.45 KiB [emitted] (name: main) 1 related asset
|
434
|
-
|
435
|
-
asset index.html 4.98 KiB [emitted]
|
436
|
-
|
437
|
-
asset about/index.html 1.75 KiB [emitted]
|
438
|
-
|
439
|
-
Entrypoint main 392 KiB (449 KiB) = assets/stylesheet/bundle.css 5.45 KiB assets/javascript/bundle.js 387 KiB 2 auxiliary assets
|
440
|
-
|
441
|
-
runtime modules 1.25 KiB 6 modules
|
442
|
-
|
443
|
-
modules by path ./node_modules/ 361 KiB
|
444
|
-
|
445
|
-
modules by path ./node_modules/webpack-dev-server/ 21.2 KiB 12 modules
|
446
|
-
|
447
|
-
modules by path ./node_modules/html-entities/lib/.js 61 KiB 5 modules
|
448
|
-
|
449
|
-
modules by path ./node_modules/@babel/runtime/ 1.55 KiB 4 modules
|
450
|
-
|
451
|
-
modules by path ./node_modules/webpack/hot/ 1.58 KiB 3 modules
|
452
|
-
|
453
|
-
modules by path ./node_modules/querystring/.js 4.51 KiB 3 modules
|
454
|
-
|
455
|
-
modules by path ./node_modules/url/.js 23.1 KiB 2 modules
|
456
|
-
|
457
|
-
modules by path ./src/ 4.31 KiB (javascript) 5.42 KiB (css/mini-extract)
|
458
|
-
|
459
|
-
modules by path ./src/js/ 4.27 KiB 3 modules
|
460
|
-
|
461
|
-
modules by path ./src/scss/ *.scss 50 bytes (javascript) 5.42 KiB (css/mini-extract)
|
462
|
-
|
463
|
-
./src/scss/app.scss 50 bytes [built] [code generated]
|
464
|
-
|
465
|
-
css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[1].use[2]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[1].use[3]!./src/scss/app.scss 5.42 KiB [code generated]
|
466
|
-
|
467
|
-
Entrypoint HtmlWebpackPlugin_0-0 =
|
468
|
-
|
469
|
-
Entrypoint HtmlWebpackPlugin_1-0 =
|
470
|
-
|
471
|
-
runtime modules 1.43 KiB 8 modules
|
472
|
-
|
473
|
-
cacheable modules 9.14 KiB
|
474
|
-
|
475
|
-
data:text/javascript,__webpack_public_path__ = __webpack_base_uri__ = htmlWebpackPluginPublicPath; 77 bytes [built] [code generated]
|
476
|
-
|
477
|
-
./node_modules/html-webpack-plugin/lib/loader.js!./src/ejs/index.ejs 6.22 KiB [built] [code generated]
|
478
|
-
|
479
|
-
./node_modules/html-webpack-plugin/lib/loader.js!./src/ejs/about/index.ejs 2.85 KiB [built] [code generated]
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
Child HtmlWebpackCompiler compiled successfully
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
Entrypoint child =
|
488
|
-
|
489
|
-
runtime modules 937 bytes 4 modules
|
490
|
-
|
491
|
-
cacheable modules 21 KiB
|
492
|
-
|
493
|
-
./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[1].use[2]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[1].use[3]!./src/scss/app.scss 17.3 KiB [built] [code generated]
|
494
|
-
|
495
|
-
./node_modules/css-loader/dist/runtime/cssWithMappingToString.js 2.21 KiB [built] [code generated]
|
496
|
-
|
497
|
-
./node_modules/css-loader/dist/runtime/api.js 1.57 KiB [built] [code generated]
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
Child mini-css-extract-plugin /path/to/dir/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].use[1]!/path/to/dir/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[1].use[2]!/path/to/dir/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[1].use[3]!/path/to/dir/src/scss/app.scss compiled successfully
|
502
|
-
|
503
|
-
webpack 5.28.0 compiled successfully in 1357 ms
|
504
|
-
|
505
|
-
ℹ 「wdm」: Compiled successfully.
|
506
|
-
|
507
|
-
```
|
508
|
-
|
509
537
|
|
510
538
|
|
511
539
|
* npm startによってdevserverが実行されます
|
1
webpack-dev-serverの記述を変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
|
13
|
-
開発の際にwebpack-dev-server(以下
|
13
|
+
開発の際にwebpack-dev-server(以下devserver)を実行しブラウザ上でファイルの変更を確認しているのですが、ejsのテンプレートファイルがwatch対象になっておらずリアルタイムで変更が反映されずに困っています。
|
14
14
|
|
15
15
|
原因または解決策のご教授をお願いしたいです。
|
16
16
|
|
@@ -20,9 +20,9 @@
|
|
20
20
|
|
21
21
|
|
22
22
|
|
23
|
-
*
|
23
|
+
* devserverを実行してもtemplateディレクトリ内にあるejsファイルの変更が監視されない
|
24
|
-
|
24
|
+
|
25
|
-
* 一度
|
25
|
+
* 一度devserverを停止し、再度実行すると差分は反映されている(リアルタイムで変更がなされない)
|
26
26
|
|
27
27
|
* templateディレクトリ以外のejsファイル、およびすべてのscss, jsファイルは問題なく監視対象となっている
|
28
28
|
|
@@ -404,7 +404,7 @@
|
|
404
404
|
|
405
405
|
|
406
406
|
|
407
|
-
######
|
407
|
+
###### devserver起動時のログ
|
408
408
|
|
409
409
|
```
|
410
410
|
|
@@ -508,7 +508,7 @@
|
|
508
508
|
|
509
509
|
|
510
510
|
|
511
|
-
* npm startによって
|
511
|
+
* npm startによってdevserverが実行されます
|
512
512
|
|
513
513
|
* ejsファイルはejs-compiled-loaderを通りhtml-webpack-pluginによって自動生成されます。
|
514
514
|
|
@@ -520,7 +520,7 @@
|
|
520
520
|
|
521
521
|
|
522
522
|
|
523
|
-
*
|
523
|
+
* devserverの問題かと思いwebpackのwatchモードを実行してみましたが、同様にtamplateディレクトリ内のejsファイルのみ監視対象となりませんでした
|
524
524
|
|
525
525
|
* ```ejs-html-loader```, ```ejs-plain-loader```などのその他のloaderも試してみましたが、同様の結果でした
|
526
526
|
|