8
8
* of patent rights can be found in the PATENTS file in the same directory.
9
9
*/
10
10
// @remove -on-eject-end
11
- " use strict"
12
- var autoprefixer = require ( 'autoprefixer' ) ;
13
- var webpack = require ( 'webpack' ) ;
14
- var HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ;
15
- var ExtractTextPlugin = require ( 'extract-text-webpack-plugin' ) ;
16
- var ManifestPlugin = require ( 'webpack-manifest-plugin' ) ;
17
- var InterpolateHtmlPlugin = require ( 'react-dev-utils/InterpolateHtmlPlugin' ) ;
18
- var paths = require ( './paths' ) ;
19
- var getClientEnvironment = require ( './env' ) ;
20
- var isProduction = require ( 'react-dev-utils/isProduction' ) ;
11
+ ' use strict' ;
12
+ const autoprefixer = require ( 'autoprefixer' ) ;
13
+ const webpack = require ( 'webpack' ) ;
14
+ const HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ;
15
+ const ExtractTextPlugin = require ( 'extract-text-webpack-plugin' ) ;
16
+ const ManifestPlugin = require ( 'webpack-manifest-plugin' ) ;
17
+ const InterpolateHtmlPlugin = require ( 'react-dev-utils/InterpolateHtmlPlugin' ) ;
18
+ const paths = require ( './paths' ) ;
19
+ const getClientEnvironment = require ( './env' ) ;
20
+ const isProduction = require ( 'react-dev-utils/isProduction' ) ;
21
21
22
22
// @remove -on-eject-begin
23
23
// `path` is not used after eject - see https://github.com/facebookincubator/create-react-app/issues/1174
24
- var path = require ( 'path' ) ;
24
+ const path = require ( 'path' ) ;
25
25
// @remove -on-eject-end
26
26
27
27
// Webpack uses `publicPath` to determine where the app is being served from.
28
28
// It requires a trailing slash, or the file assets will get an incorrect path.
29
- var publicPath = paths . servedPath ;
29
+ const publicPath = paths . servedPath ;
30
30
// Some apps do not use client-side routing with pushState.
31
31
// For these, "homepage" can be set to "." to enable relative asset paths.
32
- var shouldUseRelativeAssetPaths = publicPath === './' ;
32
+ const shouldUseRelativeAssetPaths = publicPath === './' ;
33
33
// `publicUrl` is just like `publicPath`, but we will provide it to our app
34
34
// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
35
35
// Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
36
- var publicUrl = publicPath . slice ( 0 , - 1 ) ;
36
+ const publicUrl = publicPath . slice ( 0 , - 1 ) ;
37
37
// Get environment variables to inject into our app.
38
- var env = getClientEnvironment ( publicUrl ) ;
38
+ const env = getClientEnvironment ( publicUrl ) ;
39
39
40
40
// Fall back to development if not production
41
41
if ( env . stringified [ 'process.env' ] . NODE_ENV !== '"production"' ) {
@@ -72,11 +72,11 @@ module.exports = {
72
72
// We don't currently advertise code splitting but Webpack supports it.
73
73
// There's prefix in the filename to identify which NODE_ENV generated this build
74
74
filename : 'static/js/' + process . env . NODE_ENV + '.[name].[chunkhash:8].js' ,
75
- chunkFilename : (
76
- 'static/js/' + process . env . NODE_ENV + '.[name].[chunkhash:8].chunk.js'
77
- ) ,
75
+ chunkFilename : 'static/js/' +
76
+ process . env . NODE_ENV +
77
+ '.[name].[chunkhash:8].chunk.js' ,
78
78
// We inferred the "public path" (such as / or /my-project) from homepage.
79
- publicPath : publicPath
79
+ publicPath : publicPath ,
80
80
} ,
81
81
resolve : {
82
82
// This allows you to set a fallback for where Webpack should look for modules.
@@ -93,8 +93,8 @@ module.exports = {
93
93
alias : {
94
94
// Support React Native Web
95
95
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
96
- 'react-native' : 'react-native-web'
97
- }
96
+ 'react-native' : 'react-native-web' ,
97
+ } ,
98
98
} ,
99
99
// @remove -on-eject-begin
100
100
// Resolve loaders (webpack plugins for CSS, images, transpilation) from the
@@ -103,8 +103,8 @@ module.exports = {
103
103
modules : [
104
104
paths . ownNodeModules ,
105
105
// Lerna hoists everything, so we need to look in our app directory
106
- paths . appNodeModules
107
- ]
106
+ paths . appNodeModules ,
107
+ ] ,
108
108
} ,
109
109
// @remove -on-eject-end
110
110
// This part is essentially the same as production configuration, but it remove
@@ -126,13 +126,13 @@ module.exports = {
126
126
// TODO: consider separate config for production,
127
127
// e.g. to enable no-console and no-debugger only in production.
128
128
configFile : path . join ( __dirname , '../.eslintrc' ) ,
129
- useEslintrc : false
129
+ useEslintrc : false ,
130
130
} ,
131
131
// @remove -on-eject-end
132
- loader : 'eslint-loader'
133
- }
132
+ loader : 'eslint-loader' ,
133
+ } ,
134
134
] ,
135
- include : paths . appSrc
135
+ include : paths . appSrc ,
136
136
} ,
137
137
// ** ADDING/UPDATING LOADERS **
138
138
// The "url" loader handles all assets unless explicitly excluded.
@@ -147,10 +147,10 @@ module.exports = {
147
147
loader : 'url-loader' ,
148
148
options : {
149
149
limit : 10000 ,
150
- name : (
151
- 'static/media/' + process . env . NODE_ENV + '.[name].[hash:8].[ext]'
152
- )
153
- }
150
+ name : 'static/media/' +
151
+ process . env . NODE_ENV +
152
+ '.[name].[hash:8].[ext]' ,
153
+ } ,
154
154
} ,
155
155
// Process JS with Babel.
156
156
{
@@ -160,9 +160,8 @@ module.exports = {
160
160
// @remove -on-eject-begin
161
161
options : {
162
162
babelrc : false ,
163
- presets : [ require . resolve ( 'babel-preset-react-app' ) ]
164
- }
165
-
163
+ presets : [ require . resolve ( 'babel-preset-react-app' ) ] ,
164
+ } ,
166
165
// @remove -on-eject-end
167
166
} ,
168
167
// The notation here is somewhat confusing.
@@ -187,8 +186,8 @@ module.exports = {
187
186
{
188
187
loader : 'css-loader' ,
189
188
options : {
190
- importLoaders : 1
191
- }
189
+ importLoaders : 1 ,
190
+ } ,
192
191
} ,
193
192
{
194
193
loader : 'postcss-loader' ,
@@ -201,34 +200,33 @@ module.exports = {
201
200
'>1%' ,
202
201
'last 4 versions' ,
203
202
'Firefox ESR' ,
204
- 'not ie < 9' // React doesn't support IE8 anyway
205
- ]
206
- } )
203
+ 'not ie < 9' , // React doesn't support IE8 anyway
204
+ ] ,
205
+ } ) ,
207
206
] ;
208
- }
209
- }
210
- }
211
- ]
207
+ } ,
208
+ } ,
209
+ } ,
210
+ ] ,
212
211
} ,
213
212
extractTextPluginOptions
214
213
)
215
- )
216
-
214
+ ) ,
217
215
// Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
218
216
} ,
219
217
// "file" loader for svg
220
218
{
221
219
test : / \. s v g $ / ,
222
220
loader : 'file-loader' ,
223
221
options : {
224
- name : (
225
- 'static/media/' + process . env . NODE_ENV + '.[name].[hash:8].[ext]'
226
- )
227
- }
228
- }
222
+ name : 'static/media/' +
223
+ process . env . NODE_ENV +
224
+ '.[name].[hash:8].[ext]' ,
225
+ } ,
226
+ } ,
229
227
// ** STOP ** Are you adding a new loader?
230
228
// Remember to add the new extension(s) to the "url" loader exclusion list.
231
- ]
229
+ ] ,
232
230
} ,
233
231
plugins : [
234
232
// Makes some environment variables available in index.html.
@@ -241,23 +239,21 @@ module.exports = {
241
239
new HtmlWebpackPlugin ( {
242
240
inject : true ,
243
241
template : paths . appHtml ,
244
- minify : (
245
- isProduction ( )
246
- ? // Minify the code if in production.
247
- {
248
- removeComments : true ,
249
- collapseWhitespace : true ,
250
- removeRedundantAttributes : true ,
251
- useShortDoctype : true ,
252
- removeEmptyAttributes : true ,
253
- removeStyleLinkTypeAttributes : true ,
254
- keepClosingSlash : true ,
255
- minifyJS : true ,
256
- minifyCSS : true ,
257
- minifyURLs : true
258
- }
259
- : false
260
- )
242
+ minify : isProduction ( )
243
+ ? // Minify the code if in production.
244
+ {
245
+ removeComments : true ,
246
+ collapseWhitespace : true ,
247
+ removeRedundantAttributes : true ,
248
+ useShortDoctype : true ,
249
+ removeEmptyAttributes : true ,
250
+ removeStyleLinkTypeAttributes : true ,
251
+ keepClosingSlash : true ,
252
+ minifyJS : true ,
253
+ minifyCSS : true ,
254
+ minifyURLs : true ,
255
+ }
256
+ : false ,
261
257
} ) ,
262
258
// Makes some environment variables available to the JS code, for example:
263
259
// if (process.env.NODE_ENV === 'production') { ... }. See `./env.js`.
@@ -269,35 +265,35 @@ module.exports = {
269
265
? new webpack . optimize . UglifyJsPlugin ( {
270
266
compress : {
271
267
screw_ie8 : true , // React doesn't support IE8
272
- warnings : false
268
+ warnings : false ,
273
269
} ,
274
270
mangle : {
275
- screw_ie8 : true
271
+ screw_ie8 : true ,
276
272
} ,
277
273
output : {
278
274
comments : false ,
279
- screw_ie8 : true
275
+ screw_ie8 : true ,
280
276
} ,
281
- sourceMap : true
277
+ sourceMap : true ,
282
278
} )
283
279
: false ,
284
280
// Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`.
285
281
new ExtractTextPlugin ( {
286
- filename : cssFilename
282
+ filename : cssFilename ,
287
283
} ) ,
288
284
// Generate a manifest file which contains a mapping of all asset filenames
289
285
// to their corresponding output file so that tools can pick it up without
290
286
// having to parse `index.html`.
291
287
// We also read this file to delete stale files in build folder
292
288
new ManifestPlugin ( {
293
- fileName : 'asset-manifest.json'
294
- } )
289
+ fileName : 'asset-manifest.json' ,
290
+ } ) ,
295
291
] . filter ( Boolean ) , // remove falsy plugin on development
296
292
// Some libraries import Node modules but don't use them in the browser.
297
293
// Tell Webpack to provide empty mocks for them so importing them works.
298
294
node : {
299
295
fs : 'empty' ,
300
296
net : 'empty' ,
301
- tls : 'empty'
302
- }
303
- } ;
297
+ tls : 'empty' ,
298
+ } ,
299
+ } ;
0 commit comments