質問編集履歴
1
ソースコードの記入
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
rails-webpack でreact を動かそうとしている。
|
2
2
|
|
3
|
+
```
|
4
|
+
|
5
|
+
|
6
|
+
|
3
|
-
|
7
|
+
webブラウザのコンソール
|
8
|
+
|
9
|
+
|
4
10
|
|
5
11
|
Uncaught Error: Module build failed (from ./node_modules/babel-loader/lib/index.js):
|
6
12
|
|
@@ -107,3 +113,281 @@
|
|
107
113
|
|
108
114
|
|
109
115
|
```
|
116
|
+
|
117
|
+
途中でherokuにアップロードしようとしてエラーが出てしまい一度webpackerを入れ直したらこうなりました。
|
118
|
+
|
119
|
+
jsxファイルが読み込めないとのことですが入れ直す前は正常に動いていました。どうすれば元に戻るでしょうか?
|
120
|
+
|
121
|
+
```ここに言語を入力
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
/webpacker.yml
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
# Note: You must restart bin/webpack-dev-server for changes to take effect
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
default: &default
|
134
|
+
|
135
|
+
source_path: app/javascript
|
136
|
+
|
137
|
+
source_entry_path: packs
|
138
|
+
|
139
|
+
public_root_path: public
|
140
|
+
|
141
|
+
public_output_path: packs
|
142
|
+
|
143
|
+
cache_path: tmp/cache/webpacker
|
144
|
+
|
145
|
+
webpack_compile_output: true
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
# Additional paths webpack should lookup modules
|
150
|
+
|
151
|
+
# ['app/assets', 'engine/foo/app/assets']
|
152
|
+
|
153
|
+
additional_paths: []
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
# Reload manifest.json on all requests so we reload latest compiled packs
|
158
|
+
|
159
|
+
cache_manifest: false
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
# Extract and emit a css file
|
164
|
+
|
165
|
+
extract_css: false
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
static_assets_extensions:
|
170
|
+
|
171
|
+
- .jpg
|
172
|
+
|
173
|
+
- .jpeg
|
174
|
+
|
175
|
+
- .png
|
176
|
+
|
177
|
+
- .gif
|
178
|
+
|
179
|
+
- .tiff
|
180
|
+
|
181
|
+
- .ico
|
182
|
+
|
183
|
+
- .svg
|
184
|
+
|
185
|
+
- .eot
|
186
|
+
|
187
|
+
- .otf
|
188
|
+
|
189
|
+
- .ttf
|
190
|
+
|
191
|
+
- .woff
|
192
|
+
|
193
|
+
- .woff2
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
extensions:
|
198
|
+
|
199
|
+
- .jsx
|
200
|
+
|
201
|
+
- .mjs
|
202
|
+
|
203
|
+
- .js
|
204
|
+
|
205
|
+
- .sass
|
206
|
+
|
207
|
+
- .scss
|
208
|
+
|
209
|
+
- .css
|
210
|
+
|
211
|
+
- .module.sass
|
212
|
+
|
213
|
+
- .module.scss
|
214
|
+
|
215
|
+
- .module.css
|
216
|
+
|
217
|
+
- .png
|
218
|
+
|
219
|
+
- .svg
|
220
|
+
|
221
|
+
- .gif
|
222
|
+
|
223
|
+
- .jpeg
|
224
|
+
|
225
|
+
- .jpg
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
development:
|
230
|
+
|
231
|
+
<<: *default
|
232
|
+
|
233
|
+
compile: true
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
# Reference: https://webpack.js.org/configuration/dev-server/
|
238
|
+
|
239
|
+
dev_server:
|
240
|
+
|
241
|
+
https: false
|
242
|
+
|
243
|
+
host: localhost
|
244
|
+
|
245
|
+
port: 3035
|
246
|
+
|
247
|
+
public: localhost:3035
|
248
|
+
|
249
|
+
hmr: false
|
250
|
+
|
251
|
+
# Inline should be set to true if using HMR
|
252
|
+
|
253
|
+
inline: true
|
254
|
+
|
255
|
+
overlay: true
|
256
|
+
|
257
|
+
compress: true
|
258
|
+
|
259
|
+
disable_host_check: true
|
260
|
+
|
261
|
+
use_local_ip: false
|
262
|
+
|
263
|
+
quiet: false
|
264
|
+
|
265
|
+
pretty: false
|
266
|
+
|
267
|
+
headers:
|
268
|
+
|
269
|
+
'Access-Control-Allow-Origin': '*'
|
270
|
+
|
271
|
+
watch_options:
|
272
|
+
|
273
|
+
ignored: '**/node_modules/**'
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
test:
|
280
|
+
|
281
|
+
<<: *default
|
282
|
+
|
283
|
+
compile: true
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
# Compile test packs to a separate directory
|
288
|
+
|
289
|
+
public_output_path: packs-test
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
production:
|
294
|
+
|
295
|
+
<<: *default
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
# Production depends on precompilation of packs prior to booting for performance.
|
300
|
+
|
301
|
+
compile: false
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
# Extract and emit a css file
|
306
|
+
|
307
|
+
extract_css: true
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
# Cache manifest.json for performance
|
312
|
+
|
313
|
+
cache_manifest: true
|
314
|
+
|
315
|
+
```
|
316
|
+
|
317
|
+
application.html.erb
|
318
|
+
|
319
|
+
```html
|
320
|
+
|
321
|
+
<!DOCTYPE html>
|
322
|
+
|
323
|
+
<html>
|
324
|
+
|
325
|
+
<head>
|
326
|
+
|
327
|
+
<title>RailsMemo</title>
|
328
|
+
|
329
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
330
|
+
|
331
|
+
<%= csrf_meta_tags %>
|
332
|
+
|
333
|
+
<%= csp_meta_tag %>
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
<%= stylesheet_link_tag 'application', media: 'all' %>
|
340
|
+
|
341
|
+
<%= javascript_pack_tag 'application' %>
|
342
|
+
|
343
|
+
<%= javascript_pack_tag 'index' %>
|
344
|
+
|
345
|
+
</head>
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
<body>
|
350
|
+
|
351
|
+
<%= yield %>
|
352
|
+
|
353
|
+
</body>
|
354
|
+
|
355
|
+
</html>
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
```
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
javascript/packs/index.jsx
|
364
|
+
|
365
|
+
```ここに言語を入力
|
366
|
+
|
367
|
+
import React from 'react'
|
368
|
+
|
369
|
+
import ReactDOM from 'react-dom'
|
370
|
+
|
371
|
+
import { BrowserRouter } from 'react-router-dom';
|
372
|
+
|
373
|
+
import App from '../components/App'
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
document.addEventListener('DOMContentLoaded', () => {
|
378
|
+
|
379
|
+
ReactDOM.render(
|
380
|
+
|
381
|
+
<>
|
382
|
+
|
383
|
+
<App/>
|
384
|
+
|
385
|
+
</>,
|
386
|
+
|
387
|
+
document.querySelector('#root'),
|
388
|
+
|
389
|
+
);
|
390
|
+
|
391
|
+
});
|
392
|
+
|
393
|
+
```
|