質問編集履歴
1
具体的症状を修正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Webpack
|
1
|
+
WebpackでSCSSをコンパイル時にsourcemapが生成されているのですが、元のSCSSファイルの記載場所に辿れません。
|
test
CHANGED
@@ -1,3 +1,475 @@
|
|
1
|
+
WebpackでSCSSをコンパイル時にsourcemapが生成されているのですが、chormeの検証ツールで元のSCSSファイルの記載場所に辿れません。
|
2
|
+
|
3
|
+
色々調べたのですが何が原因か全くわかりませんでした。
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
コンパイル時に外部ライブラリのCSSも一緒にコンパイルしているのですが原因でしょうか?
|
8
|
+
|
9
|
+
一応、外してコンパイルしたのですがダメでした。
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
以下、設定を記載します。よろしくお願いします。
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
**index.js**
|
18
|
+
|
19
|
+
```ここに言語を入力
|
20
|
+
|
21
|
+
import '../scss/library/XXXXX.css';
|
22
|
+
|
23
|
+
import '../scss/style.scss';
|
24
|
+
|
25
|
+
```
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
**package.json**
|
30
|
+
|
31
|
+
```ここに言語を入力
|
32
|
+
|
33
|
+
{
|
34
|
+
|
35
|
+
"name": "webpack",
|
36
|
+
|
37
|
+
"version": "1.0.0",
|
38
|
+
|
39
|
+
"description": "test",
|
40
|
+
|
41
|
+
"private": true,
|
42
|
+
|
43
|
+
"main": "index.js",
|
44
|
+
|
45
|
+
"scripts": {
|
46
|
+
|
47
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
48
|
+
|
49
|
+
"dev": "webpack --mode development",
|
50
|
+
|
51
|
+
"build": "webpack --mode production",
|
52
|
+
|
53
|
+
"watch": "webpack --mode development --watch",
|
54
|
+
|
55
|
+
"start": "webpack-dev-server"
|
56
|
+
|
57
|
+
},
|
58
|
+
|
59
|
+
"keywords": [],
|
60
|
+
|
61
|
+
"author": "",
|
62
|
+
|
63
|
+
"license": "ISC",
|
64
|
+
|
65
|
+
"devDependencies": {
|
66
|
+
|
67
|
+
"@babel/core": "^7.10.2",
|
68
|
+
|
69
|
+
"@babel/polyfill": "^7.10.1",
|
70
|
+
|
71
|
+
"@babel/preset-env": "^7.10.2",
|
72
|
+
|
73
|
+
"autoprefixer": "^9.8.0",
|
74
|
+
|
75
|
+
"babel-loader": "^8.1.0",
|
76
|
+
|
77
|
+
"clean-webpack-plugin": "^3.0.0",
|
78
|
+
|
79
|
+
"copy-webpack-plugin": "^6.0.2",
|
80
|
+
|
81
|
+
"css-loader": "^3.5.3",
|
82
|
+
|
83
|
+
"ejs": "^3.1.3",
|
84
|
+
|
85
|
+
"ejs-plain-loader": "^1.4.1",
|
86
|
+
|
87
|
+
"file-loader": "^6.0.0",
|
88
|
+
|
89
|
+
"html-loader": "^1.1.0",
|
90
|
+
|
91
|
+
"html-webpack-plugin": "^4.3.0",
|
92
|
+
|
93
|
+
"imagemin-gifsicle": "^7.0.0",
|
94
|
+
|
95
|
+
"imagemin-mozjpeg": "^9.0.0",
|
96
|
+
|
97
|
+
"imagemin-pngquant": "^9.0.0",
|
98
|
+
|
99
|
+
"imagemin-svgo": "^8.0.0",
|
100
|
+
|
101
|
+
"imagemin-webpack-plugin": "^2.4.2",
|
102
|
+
|
103
|
+
"imagesloaded": "^4.1.4",
|
104
|
+
|
105
|
+
"import-glob-loader": "^1.1.0",
|
106
|
+
|
107
|
+
"jquery": "^3.5.1",
|
108
|
+
|
109
|
+
"mini-css-extract-plugin": "^0.9.0",
|
110
|
+
|
111
|
+
"node-sass": "^4.14.1",
|
112
|
+
|
113
|
+
"postcss-loader": "^3.0.0",
|
114
|
+
|
115
|
+
"sass-loader": "^8.0.2",
|
116
|
+
|
117
|
+
"style-loader": "^1.2.1",
|
118
|
+
|
119
|
+
"stylelint": "^13.6.0",
|
120
|
+
|
121
|
+
"stylelint-webpack-plugin": "^2.0.0",
|
122
|
+
|
123
|
+
"url-loader": "^4.1.0",
|
124
|
+
|
125
|
+
"webpack": "^4.43.0",
|
126
|
+
|
127
|
+
"webpack-cli": "^3.3.11",
|
128
|
+
|
1
|
-
|
129
|
+
"webpack-dev-server": "^3.11.0"
|
130
|
+
|
2
|
-
|
131
|
+
},
|
132
|
+
|
133
|
+
"dependencies": {
|
134
|
+
|
135
|
+
"jquery": "^3.5.1",
|
136
|
+
|
137
|
+
"tether": "^1.4.7"
|
138
|
+
|
139
|
+
},
|
140
|
+
|
141
|
+
"browserslist": [
|
142
|
+
|
143
|
+
"last 2 versions",
|
144
|
+
|
145
|
+
"ie >= 11",
|
146
|
+
|
147
|
+
"Android 4.0"
|
148
|
+
|
149
|
+
]
|
150
|
+
|
151
|
+
}
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
```
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
**webpack.config.js**
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
```ここに言語を入力
|
164
|
+
|
165
|
+
const path = require('path');
|
166
|
+
|
167
|
+
const webpack = require('webpack');
|
168
|
+
|
169
|
+
//html
|
170
|
+
|
171
|
+
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
172
|
+
|
173
|
+
//CSS
|
174
|
+
|
175
|
+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
176
|
+
|
177
|
+
const StylelintPlugin = require('stylelint-webpack-plugin');
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
const CopyPlugin = require('copy-webpack-plugin');
|
182
|
+
|
183
|
+
const ImageminPlugin = require('imagemin-webpack-plugin').default;
|
184
|
+
|
185
|
+
const ImageminMozjpeg = require('imagemin-mozjpeg');
|
186
|
+
|
187
|
+
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
module.exports = {
|
194
|
+
|
195
|
+
entry: {
|
196
|
+
|
197
|
+
'index': path.join(__dirname, '/src/js/index.js'),
|
198
|
+
|
199
|
+
},
|
200
|
+
|
201
|
+
devtool: 'source-map',
|
202
|
+
|
203
|
+
output: {
|
204
|
+
|
205
|
+
filename: 'js/[name].[hash].js',
|
206
|
+
|
207
|
+
path: path.resolve(__dirname, 'dist')
|
208
|
+
|
209
|
+
},
|
210
|
+
|
211
|
+
devServer: {
|
212
|
+
|
213
|
+
contentBase: `${__dirname}/dist`,
|
214
|
+
|
215
|
+
watchContentBase: true,
|
216
|
+
|
217
|
+
historyApiFallback: true,
|
218
|
+
|
219
|
+
compress: true,
|
220
|
+
|
221
|
+
port: 8080,
|
222
|
+
|
223
|
+
open: true,
|
224
|
+
|
225
|
+
inline: true
|
226
|
+
|
227
|
+
},
|
228
|
+
|
229
|
+
module:{
|
230
|
+
|
231
|
+
rules: [
|
232
|
+
|
233
|
+
{
|
234
|
+
|
235
|
+
test: /.js$/,
|
236
|
+
|
237
|
+
exclude: /node_modules/,
|
238
|
+
|
239
|
+
use:
|
240
|
+
|
241
|
+
{
|
242
|
+
|
243
|
+
loader: 'babel-loader',
|
244
|
+
|
245
|
+
options: {
|
246
|
+
|
247
|
+
presets: [
|
248
|
+
|
249
|
+
'@babel/preset-env',
|
250
|
+
|
251
|
+
]
|
252
|
+
|
253
|
+
}
|
254
|
+
|
255
|
+
}
|
256
|
+
|
257
|
+
},
|
258
|
+
|
259
|
+
{
|
260
|
+
|
261
|
+
test: /.(jpg|png|gif|svg)$/,
|
262
|
+
|
263
|
+
use: {
|
264
|
+
|
265
|
+
loader: 'file-loader',
|
266
|
+
|
267
|
+
options: {
|
268
|
+
|
269
|
+
name: '/img/[name].[hash].[ext]',
|
270
|
+
|
271
|
+
}
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
},
|
276
|
+
|
277
|
+
{
|
278
|
+
|
3
|
-
|
279
|
+
test:/.(scss|css)$/,
|
280
|
+
|
281
|
+
use:[
|
282
|
+
|
283
|
+
{
|
284
|
+
|
285
|
+
loader: MiniCssExtractPlugin.loader,
|
286
|
+
|
287
|
+
},
|
288
|
+
|
289
|
+
{
|
290
|
+
|
291
|
+
loader: 'css-loader',
|
292
|
+
|
293
|
+
options: {
|
294
|
+
|
295
|
+
url: false,
|
296
|
+
|
297
|
+
sourceMap: true
|
298
|
+
|
299
|
+
},
|
300
|
+
|
301
|
+
},
|
302
|
+
|
303
|
+
{
|
304
|
+
|
305
|
+
loader: 'postcss-loader',
|
306
|
+
|
307
|
+
options: {
|
308
|
+
|
309
|
+
plugins: [
|
310
|
+
|
311
|
+
require('autoprefixer')({
|
312
|
+
|
313
|
+
grid: 'autoplace'
|
314
|
+
|
315
|
+
}),
|
316
|
+
|
317
|
+
]
|
318
|
+
|
319
|
+
}
|
320
|
+
|
321
|
+
},
|
322
|
+
|
323
|
+
{
|
324
|
+
|
325
|
+
loader: 'sass-loader',
|
326
|
+
|
327
|
+
options: {
|
328
|
+
|
329
|
+
sassOptions: {
|
330
|
+
|
331
|
+
outputStyle: 'compressed',
|
332
|
+
|
333
|
+
sourceMap: true
|
334
|
+
|
335
|
+
},
|
336
|
+
|
337
|
+
},
|
338
|
+
|
339
|
+
},
|
340
|
+
|
341
|
+
{
|
342
|
+
|
343
|
+
loader: 'import-glob-loader',
|
344
|
+
|
345
|
+
},
|
346
|
+
|
347
|
+
]
|
348
|
+
|
349
|
+
},
|
350
|
+
|
351
|
+
{
|
352
|
+
|
353
|
+
test: /.ejs$/i,
|
354
|
+
|
355
|
+
use: [
|
356
|
+
|
357
|
+
{
|
358
|
+
|
359
|
+
loader: 'html-loader',
|
360
|
+
|
361
|
+
options: {
|
362
|
+
|
363
|
+
minimize: false
|
364
|
+
|
365
|
+
},
|
366
|
+
|
367
|
+
},
|
368
|
+
|
369
|
+
{
|
370
|
+
|
371
|
+
loader: 'ejs-plain-loader'
|
372
|
+
|
373
|
+
}
|
374
|
+
|
375
|
+
]
|
376
|
+
|
377
|
+
},
|
378
|
+
|
379
|
+
]
|
380
|
+
|
381
|
+
},
|
382
|
+
|
383
|
+
plugins: [
|
384
|
+
|
385
|
+
new HtmlWebpackPlugin({
|
386
|
+
|
387
|
+
filename: 'index.html',
|
388
|
+
|
389
|
+
template : 'src/ejs/index.ejs',
|
390
|
+
|
391
|
+
minify: false,
|
392
|
+
|
393
|
+
}),
|
394
|
+
|
395
|
+
new HtmlWebpackPlugin({
|
396
|
+
|
397
|
+
filename: 'about/index.html',
|
398
|
+
|
399
|
+
template : 'src/ejs/about.ejs',
|
400
|
+
|
401
|
+
minify: false,
|
402
|
+
|
403
|
+
}),
|
404
|
+
|
405
|
+
new CleanWebpackPlugin({
|
406
|
+
|
407
|
+
cleanOnceBeforeBuildPatterns: [`${__dirname}/dist/js/*.*.js`, `${__dirname}/dist/css/*.*.css`]
|
408
|
+
|
409
|
+
}),
|
410
|
+
|
411
|
+
new MiniCssExtractPlugin({
|
412
|
+
|
413
|
+
filename: 'css/style.[hash].css',
|
414
|
+
|
415
|
+
}),
|
416
|
+
|
417
|
+
new StylelintPlugin({
|
418
|
+
|
419
|
+
fix: true,
|
420
|
+
|
421
|
+
}),
|
422
|
+
|
423
|
+
new CopyPlugin({
|
424
|
+
|
425
|
+
patterns: [
|
426
|
+
|
427
|
+
{ from: 'src/img', to: 'img' }
|
428
|
+
|
429
|
+
],
|
430
|
+
|
431
|
+
}),
|
432
|
+
|
433
|
+
new ImageminPlugin({
|
434
|
+
|
435
|
+
test: /.(jpe?g|png|gif|svg)$/i,
|
436
|
+
|
437
|
+
pngquant: {
|
438
|
+
|
439
|
+
quality: '65-80'
|
440
|
+
|
441
|
+
},
|
442
|
+
|
443
|
+
gifsicle: {
|
444
|
+
|
445
|
+
interlaced: false,
|
446
|
+
|
447
|
+
optimizationLevel: 1,
|
448
|
+
|
449
|
+
colors: 256
|
450
|
+
|
451
|
+
},
|
452
|
+
|
453
|
+
svgo: {
|
454
|
+
|
455
|
+
},
|
456
|
+
|
457
|
+
plugins: [
|
458
|
+
|
459
|
+
ImageminMozjpeg({
|
460
|
+
|
461
|
+
quality: 60,
|
462
|
+
|
463
|
+
progressive: false
|
464
|
+
|
465
|
+
})
|
466
|
+
|
467
|
+
]
|
468
|
+
|
469
|
+
}),
|
470
|
+
|
471
|
+
]
|
472
|
+
|
473
|
+
}
|
474
|
+
|
475
|
+
```
|