@@ -55,8 +55,8 @@ const cssFilename = 'static/css/[name].[contenthash:8].css';
55
55
// To have this structure working with relative paths, we have to use custom options.
56
56
const extractTextPluginOptions = shouldUseRelativeAssetPaths
57
57
// Making sure that the publicPath goes back to to build folder.
58
- ? { publicPath : Array ( cssFilename . split ( '/' ) . length ) . join ( '../' ) }
59
- : undefined ;
58
+ ? { publicPath : Array ( cssFilename . split ( '/' ) . length ) . join ( '../' ) }
59
+ : { } ;
60
60
61
61
// This is the production configuration.
62
62
// It compiles slowly and is focused on producing a fast and minimal bundle.
@@ -86,15 +86,15 @@ module.exports = {
86
86
resolve : {
87
87
// This allows you to set a fallback for where Webpack should look for modules.
88
88
// We read `NODE_PATH` environment variable in `paths.js` and pass paths here.
89
- // We use `fallback` instead of `root` because we want `node_modules` to "win"
90
- // if there any conflicts. This matches Node resolution mechanism.
89
+ // We placed these paths second because we want `node_modules` to "win"
90
+ // if there are any conflicts. This matches Node resolution mechanism.
91
91
// https://github.com/facebookincubator/create-react-app/issues/253
92
- fallback : paths . nodePaths ,
92
+ modules : [ 'node_modules' ] . concat ( paths . nodePaths ) ,
93
93
// These are the reasonable defaults supported by the Node ecosystem.
94
94
// We also include JSX as a common component filename extension to support
95
95
// some tools, although we do not recommend using it, see:
96
96
// https://github.com/facebookincubator/create-react-app/issues/290
97
- extensions : [ '.js' , '.json' , '.jsx' , '' ] ,
97
+ extensions : [ '.js' , '.json' , '.jsx' ] ,
98
98
alias : {
99
99
// Support React Native Web
100
100
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
@@ -105,21 +105,34 @@ module.exports = {
105
105
// Resolve loaders (webpack plugins for CSS, images, transpilation) from the
106
106
// directory of `react-scripts` itself rather than the project directory.
107
107
resolveLoader : {
108
- root : paths . ownNodeModules ,
109
- moduleTemplates : [ '*-loader' ]
108
+ modules : [
109
+ paths . ownNodeModules ,
110
+ // Lerna hoists everything, so we need to look in our app directory
111
+ paths . appNodeModules
112
+ ]
110
113
} ,
111
114
// @remove -on-eject-end
112
115
module : {
113
- // First, run the linter.
114
- // It's important to do this before Babel processes the JS .
115
- preLoaders : [
116
+ rules : [
117
+ // First, run the linter .
118
+ // It's important to do this before Babel processes the JS.
116
119
{
117
120
test : / \. ( j s | j s x ) $ / ,
118
- loader : 'eslint' ,
121
+ enforce : 'pre' ,
122
+ use : [ {
123
+ // @remove -on-eject-begin
124
+ // Point ESLint to our predefined config.
125
+ options : {
126
+ // TODO: consider separate config for production,
127
+ // e.g. to enable no-console and no-debugger only in production.
128
+ configFile : path . join ( __dirname , '../.eslintrc' ) ,
129
+ useEslintrc : false
130
+ } ,
131
+ // @remove -on-eject-end
132
+ loader : 'eslint-loader'
133
+ } ] ,
119
134
include : paths . appSrc
120
- }
121
- ] ,
122
- loaders : [
135
+ } ,
123
136
// ** ADDING/UPDATING LOADERS **
124
137
// The "url" loader handles all assets unless explicitly excluded.
125
138
// The `exclude` list *must* be updated with every change to loader extensions.
@@ -136,8 +149,8 @@ module.exports = {
136
149
/ \. j s o n $ / ,
137
150
/ \. s v g $ /
138
151
] ,
139
- loader : 'url' ,
140
- query : {
152
+ loader : 'url-loader ' ,
153
+ options : {
141
154
limit : 10000 ,
142
155
name : 'static/media/[name].[hash:8].[ext]'
143
156
}
@@ -146,9 +159,9 @@ module.exports = {
146
159
{
147
160
test : / \. ( j s | j s x ) $ / ,
148
161
include : paths . appSrc ,
149
- loader : 'babel' ,
162
+ loader : 'babel-loader ' ,
150
163
// @remove -on-eject-begin
151
- query : {
164
+ options : {
152
165
babelrc : false ,
153
166
presets : [ require . resolve ( 'babel-preset-react-app' ) ] ,
154
167
} ,
@@ -168,42 +181,37 @@ module.exports = {
168
181
// in the main CSS file.
169
182
{
170
183
test : / \. c s s $ / ,
171
- loader : ExtractTextPlugin . extract (
172
- 'style' ,
173
- 'css?importLoaders=1!postcss' ,
174
- extractTextPluginOptions
175
- )
184
+ loader : ExtractTextPlugin . extract ( Object . assign ( {
185
+ fallback : 'style-loader' ,
186
+ use : [
187
+ {
188
+ loader : 'css-loader' ,
189
+ options : {
190
+ importLoaders : 1
191
+ }
192
+ } , {
193
+ loader : 'postcss-loader' ,
194
+ options : {
195
+ ident : 'postcss' , // https://webpack.js.org/guides/migrating/#complex-options
196
+ plugins : postcss
197
+ }
198
+ }
199
+ ]
200
+ } , extractTextPluginOptions ) )
176
201
// Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
177
202
} ,
178
- // JSON is not enabled by default in Webpack but both Node and Browserify
179
- // allow it implicitly so we also enable it.
180
- {
181
- test : / \. j s o n $ / ,
182
- loader : 'json'
183
- } ,
184
203
// "file" loader for svg
185
204
{
186
205
test : / \. s v g $ / ,
187
- loader : 'file' ,
188
- query : {
206
+ loader : 'file-loader ' ,
207
+ options : {
189
208
name : 'static/media/[name].[hash:8].[ext]'
190
209
}
191
210
}
192
211
// ** STOP ** Are you adding a new loader?
193
212
// Remember to add the new extension(s) to the "url" loader exclusion list.
194
213
]
195
214
} ,
196
- // @remove -on-eject-begin
197
- // Point ESLint to our predefined config.
198
- eslint : {
199
- // TODO: consider separate config for production,
200
- // e.g. to enable no-console and no-debugger only in production.
201
- configFile : path . join ( __dirname , '../.eslintrc' ) ,
202
- useEslintrc : false
203
- } ,
204
- // @remove -on-eject-end
205
- // We use PostCSS for autoprefixing only.
206
- postcss : postcss ,
207
215
plugins : [
208
216
// Makes some environment variables available in index.html.
209
217
// The public URL is available as %PUBLIC_URL% in index.html, e.g.:
@@ -233,10 +241,6 @@ module.exports = {
233
241
// It is absolutely essential that NODE_ENV was set to production here.
234
242
// Otherwise React will be compiled in the very slow development mode.
235
243
new webpack . DefinePlugin ( env . stringified ) ,
236
- // This helps ensure the builds are consistent if source hasn't changed:
237
- new webpack . optimize . OccurrenceOrderPlugin ( ) ,
238
- // Try to dedupe duplicated modules, if any:
239
- new webpack . optimize . DedupePlugin ( ) ,
240
244
// Minify the code.
241
245
new webpack . optimize . UglifyJsPlugin ( {
242
246
compress : {
@@ -249,10 +253,13 @@ module.exports = {
249
253
output : {
250
254
comments : false ,
251
255
screw_ie8 : true
252
- }
256
+ } ,
257
+ sourceMap : true
253
258
} ) ,
254
259
// Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`.
255
- new ExtractTextPlugin ( cssFilename ) ,
260
+ new ExtractTextPlugin ( {
261
+ filename : cssFilename
262
+ } ) ,
256
263
// Generate a manifest file which contains a mapping of all asset filenames
257
264
// to their corresponding output file so that tools can pick it up without
258
265
// having to parse `index.html`.
0 commit comments