質問編集履歴

2

追加編集しました

2020/11/20 05:50

投稿

oyu
oyu

スコア48

test CHANGED
File without changes
test CHANGED
@@ -168,7 +168,7 @@
168
168
 
169
169
  "css-loader": "^5.0.1",
170
170
 
171
- "postcss-loader": "^4.0.4",
171
+ "postcss-loader": "^4.1.0",
172
172
 
173
173
  "sass": "^1.29.0",
174
174
 
@@ -176,69 +176,101 @@
176
176
 
177
177
  "style-loader": "^2.0.0",
178
178
 
179
- "webpack": "^5.5.1",
179
+ "webpack": "^5.6.0",
180
180
 
181
181
  "webpack-cli": "^4.2.0"
182
182
 
183
+ },
184
+
185
+ "browserslist": [
186
+
187
+ "last 1 version",
188
+
189
+ "> 1%",
190
+
191
+ "IE 10"
192
+
193
+ ]
194
+
195
+ }
196
+
197
+
198
+
199
+ ```
200
+
201
+
202
+
203
+ ```ここに言語を入力
204
+
205
+ webpack.config.jsのコードになります。
206
+
207
+
208
+
209
+ const path = require('path');
210
+
211
+
212
+
213
+ module.exports = {
214
+
215
+ mode: 'development',
216
+
217
+ entry: {app: './src/app.js', sub: './src/sub.js'},
218
+
219
+ output: {
220
+
221
+ path: path.resolve(__dirname, 'public'),
222
+
223
+ filename: '[name].bundle.js'
224
+
225
+ },
226
+
227
+ module: {
228
+
229
+ rules: [
230
+
231
+ {
232
+
233
+ test: /.scss$/,
234
+
235
+ use: [
236
+
237
+ 'style-loader',
238
+
239
+ 'css-loader',
240
+
241
+ 'postcss-loader',
242
+
243
+ 'sass-loader'
244
+
245
+ ]
246
+
247
+ }
248
+
249
+ ]
250
+
183
251
  }
184
252
 
185
253
  }
186
254
 
187
-
188
-
189
- ```
255
+ ```
190
-
191
-
192
256
 
193
257
  ```ここに言語を入力
194
258
 
195
- webpack.config.jsのコードになります。
259
+ postcss.confing.jsのコードになります。
196
-
197
-
198
-
199
- const path = require('path');
200
260
 
201
261
 
202
262
 
203
263
  module.exports = {
204
264
 
265
+ plugins: [
266
+
205
- mode: 'development',
267
+ require('autoprefixer')({
206
-
268
+
207
- entry: {app: './src/app.js', sub: './src/sub.js'},
269
+ browsers: ['last 2 versions', 'ie >= 11', 'Android >= 4']
208
-
209
- output: {
270
+
210
-
211
- path: path.resolve(__dirname, 'public'),
212
-
213
- filename: '[name].bundle.js'
214
-
215
- },
271
+ })
216
-
217
- module: {
272
+
218
-
219
- rules: [
220
-
221
- {
222
-
223
- test: /.scss$/,
224
-
225
- use: [
226
-
227
- 'style-loader',
228
-
229
- 'css-loader',
230
-
231
- 'postcss-loader',
232
-
233
- 'sass-loader'
234
-
235
- ]
273
+ ]
236
-
237
- }
238
-
239
- ]
240
-
241
- }
242
274
 
243
275
  }
244
276
 

1

追加編集しました

2020/11/20 05:50

投稿

oyu
oyu

スコア48

test CHANGED
File without changes
test CHANGED
@@ -28,196 +28,218 @@
28
28
 
29
29
  ```
30
30
 
31
- PS C:\Users\81907\Desktop\workspace> npx webpack
32
-
33
- npx: 82個のパッケージを7.882秒でインストールしました。
34
-
35
- CLI for webpack must be installed.
36
-
37
- webpack-cli (https://github.com/webpack/webpack-cli)
38
-
39
-
40
-
41
- We will use "npm" to install the CLI via "npm install -D".
42
-
43
- Do you want to install 'webpack-cli' (yes/no): y
44
-
45
- Installing 'webpack-cli' (running 'npm install -D webpack-cli')...
46
-
47
- npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\81907\Desktop\workspace\package.json'
48
-
49
- npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\81907\Desktop\workspace\package.json'
50
-
51
- npm WARN webpack-cli@4.2.0 requires a peer of webpack@4.x.x || 5.x.x but none is installed. You must install peer dependencies yourself.
52
-
53
- npm WARN workspace No description
54
-
55
- npm WARN workspace No repository field.
56
-
57
- npm WARN workspace No README data
58
-
59
- npm WARN workspace No license field.
60
-
61
-
62
-
63
- + webpack-cli@4.2.0
64
-
65
- updated 1 package and audited 100 packages in 2.338s
66
-
67
-
68
-
69
- 6 packages are looking for funding
70
-
71
- run `npm fund` for details
72
-
73
-
74
-
75
- found 0 vulnerabilities
76
-
77
-
78
-
79
- Error: Cannot find module 'webpack-cli/package.json'
80
-
81
- Require stack:
82
-
83
- - C:\Users\81907\AppData\Roaming\npm-cache\_npx\1476\node_modules\webpack\bin\webpack.js
84
-
85
- at Function.Module._resolveFilename (internal/modules/cjs/loader.js:831:15)
86
-
87
- at Function.resolve (internal/modules/cjs/helpers.js:80:19)
88
-
89
- at runCli (C:\Users\81907\AppData\Roaming\npm-cache\_npx\1476\node_modules\webpack\bin\webpack.js:50:26)
90
-
91
- at C:\Users\81907\AppData\Roaming\npm-cache\_npx\1476\node_modules\webpack\bin\webpack.js:132:5
92
-
93
- at processTicksAndRejections (internal/process/task_queues.js:97:5) {
94
-
95
- code: 'MODULE_NOT_FOUND',
96
-
97
- requireStack: [
98
-
99
- 'C:\Users\81907\AppData\Roaming\npm-cache\_npx\1476\node_modules\webpack\bin\webpack.js'
100
-
101
- ]
31
+ PS C:\Users\81907\Desktop\workspace\tmp> yarn add postcss-loader autoprefixer --dev
32
+
33
+ yarn add v1.22.5
34
+
35
+ [1/4] Resolving packages...
36
+
37
+ [2/4] Fetching packages...
38
+
39
+ info fsevents@2.1.3: The platform "win32" is incompatible with this module.
40
+
41
+ info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
42
+
43
+ [3/4] Linking dependencies...
44
+
45
+ warning " > postcss-loader@4.1.0" has unmet peer dependency "postcss@^7.0.0 || ^8.0.1".
46
+
47
+ warning " > autoprefixer@10.0.2" has unmet peer dependency "postcss@^8.1.0".
48
+
49
+ [4/4] Building fresh packages...
50
+
51
+ success Saved lockfile.
52
+
53
+ success Saved 21 new dependencies.
54
+
55
+ info Direct dependencies
56
+
57
+ ├─ autoprefixer@10.0.2
58
+
59
+ └─ postcss-loader@4.1.0
60
+
61
+ info All dependencies
62
+
63
+ ├─ @babel/code-frame@7.10.4
64
+
65
+ ├─ @babel/helper-validator-identifier@7.10.4
66
+
67
+ ├─ @babel/highlight@7.10.4
68
+
69
+ ├─ @types/parse-json@4.0.0
70
+
71
+ ├─ autoprefixer@10.0.2
72
+
73
+ ├─ callsites@3.1.0
74
+
75
+ ├─ cosmiconfig@7.0.0
76
+
77
+ ├─ error-ex@1.3.2
78
+
79
+ ├─ import-fresh@3.2.2
80
+
81
+ ├─ is-arrayish@0.2.1
82
+
83
+ ├─ js-tokens@4.0.0
84
+
85
+ ├─ json-parse-even-better-errors@2.3.1
86
+
87
+ ├─ lines-and-columns@1.1.6
88
+
89
+ ├─ normalize-range@0.1.2
90
+
91
+ ├─ num2fraction@1.2.2
92
+
93
+ ├─ parent-module@1.0.1
94
+
95
+ ├─ parse-json@5.1.0
96
+
97
+ ├─ path-type@4.0.0
98
+
99
+ ├─ postcss-loader@4.1.0
100
+
101
+ ├─ resolve-from@4.0.0
102
+
103
+ └─ yaml@1.10.0
104
+
105
+ Done in 2.63s.
106
+
107
+ PS C:\Users\81907\Desktop\workspace\tmp> npx webpack
108
+
109
+ [webpack-cli] Compilation finished
110
+
111
+ asset app.bundle.js 19 KiB [emitted] (name: app)
112
+
113
+ asset sub.bundle.js 860 bytes [emitted] (name: sub)
114
+
115
+ runtime modules 931 bytes 4 modules
116
+
117
+ cacheable modules 9.16 KiB
118
+
119
+ modules by path ./src/ 951 bytes
120
+
121
+ modules by path ./src/*.js 116 bytes
122
+
123
+ ./src/app.js 79 bytes [built] [code generated]
124
+
125
+ ./src/sub.js 37 bytes [built] [code generated]
126
+
127
+ modules by path ./src/*.scss 835 bytes
128
+
129
+ ./src/app.scss 408 bytes [built] [code generated]
130
+
131
+ ./node_modules/css-loader/dist/cjs.js!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/app.scss 427 bytes [built] [code generated]
132
+
133
+ modules by path ./node_modules/ 8.23 KiB
134
+
135
+ ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js 6.67 KiB [built] [code generated]
136
+
137
+ ./node_modules/css-loader/dist/runtime/api.js 1.57 KiB [built] [code generated]
138
+
139
+ webpack 5.6.0 compiled successfully in 1340 ms
140
+
141
+ ```
142
+
143
+
144
+
145
+ ### 該当のソースコード
146
+
147
+
148
+
149
+ ```ここに言語名を入力
150
+
151
+ package.jsonコードになります。
152
+
153
+
154
+
155
+ {
156
+
157
+ "name": "tmp",
158
+
159
+ "version": "1.0.0",
160
+
161
+ "main": "index.js",
162
+
163
+ "license": "MIT",
164
+
165
+ "devDependencies": {
166
+
167
+ "autoprefixer": "^10.0.2",
168
+
169
+ "css-loader": "^5.0.1",
170
+
171
+ "postcss-loader": "^4.0.4",
172
+
173
+ "sass": "^1.29.0",
174
+
175
+ "sass-loader": "^10.1.0",
176
+
177
+ "style-loader": "^2.0.0",
178
+
179
+ "webpack": "^5.5.1",
180
+
181
+ "webpack-cli": "^4.2.0"
182
+
183
+ }
102
184
 
103
185
  }
104
186
 
187
+
188
+
105
- ```
189
+ ```
106
-
107
-
108
-
109
- ### 該当のソースコード
190
+
110
-
111
-
112
-
191
+
192
+
113
- ```ここに言語を入力
193
+ ```ここに言語を入力
114
-
194
+
115
- package.jsonコードになります。
195
+ webpack.config.jsコードになります。
196
+
197
+
198
+
116
-
199
+ const path = require('path');
200
+
201
+
202
+
117
-
203
+ module.exports = {
204
+
118
-
205
+ mode: 'development',
206
+
207
+ entry: {app: './src/app.js', sub: './src/sub.js'},
208
+
209
+ output: {
210
+
211
+ path: path.resolve(__dirname, 'public'),
212
+
213
+ filename: '[name].bundle.js'
214
+
215
+ },
216
+
217
+ module: {
218
+
219
+ rules: [
220
+
119
- {
221
+ {
120
-
121
- "name": "tmp",
222
+
122
-
123
- "version": "1.0.0",
223
+ test: /.scss$/,
124
-
125
- "main": "index.js",
224
+
126
-
127
- "license": "MIT",
225
+ use: [
128
-
226
+
129
- "devDependencies": {
227
+ 'style-loader',
130
-
131
- "autoprefixer": "^10.0.2",
228
+
132
-
133
- "css-loader": "^5.0.1",
229
+ 'css-loader',
134
-
230
+
135
- "postcss-loader": "^4.0.4",
231
+ 'postcss-loader',
136
-
137
- "sass": "^1.29.0",
232
+
138
-
139
- "sass-loader": "^10.1.0",
233
+ 'sass-loader'
140
-
141
- "style-loader": "^2.0.0",
234
+
142
-
143
- "webpack": "^5.5.1",
235
+ ]
144
-
236
+
145
- "webpack-cli": "^4.2.0"
237
+ }
238
+
239
+ ]
146
240
 
147
241
  }
148
242
 
149
243
  }
150
244
 
151
-
152
-
153
- ```
245
+ ```
154
-
155
-
156
-
157
- ```ここに言語を入力
158
-
159
- webpack.config.jsのコードになります。
160
-
161
-
162
-
163
- const path = require('path')
164
-
165
-
166
-
167
- module.exports = {
168
-
169
- mode: 'development',
170
-
171
- devtool: 'none',
172
-
173
- entry: './src/app.js',
174
-
175
- output: {
176
-
177
- path: path.resolve(__dirname, 'public'),
178
-
179
- filename: 'app.bundle.js'
180
-
181
- },
182
-
183
- module: {
184
-
185
- rules: [{
186
-
187
- test: /.scss$/,
188
-
189
- use: [
190
-
191
- 'style-loader', // htmlにstyleタグで記述する
192
-
193
- 'css-loader', // cssをimportする
194
-
195
- 'postcss-loader', // autoprefixを付与
196
-
197
- 'sass-loader', // 下から実行する //sass→cssへ
198
-
199
- plugins: [
200
-
201
- // Autoprefixerを有効化
202
-
203
- require("autoprefixer")({
204
-
205
- // ☆IEは11以上、Androidは4.4以上
206
-
207
- // その他は最新2バージョンで必要なベンダープレフィックスを付与する設定
208
-
209
- browsers: ["last 2 versions", "ie >= 11", "Android >= 4"]
210
-
211
- })
212
-
213
- ]
214
-
215
- ]
216
-
217
- }]
218
-
219
- }
220
-
221
- }
222
-
223
- ```