@@ -152,109 +152,107 @@ module.exports = {
152152 ] ,
153153 include : paths . appSrc ,
154154 } ,
155- // ** ADDING/UPDATING LOADERS **
156- // The "file" loader handles all assets unless explicitly excluded.
157- // The `exclude` list *must* be updated with every change to loader extensions.
158- // When adding a new loader, you must add its `test`
159- // as a new entry in the `exclude` list in the "file" loader.
160-
161- // "file" loader makes sure those assets end up in the `build` folder.
162- // When you `import` an asset, you get its filename.
163- {
164- exclude : [
165- / \. h t m l $ / ,
166- / \. ( j s | j s x ) $ / ,
167- / \. c s s $ / ,
168- / \. j s o n $ / ,
169- / \. b m p $ / ,
170- / \. g i f $ / ,
171- / \. j p e ? g $ / ,
172- / \. p n g $ / ,
173- ] ,
174- loader : require . resolve ( 'file-loader' ) ,
175- options : {
176- name : 'static/media/[name].[hash:8].[ext]' ,
177- } ,
178- } ,
179- // "url" loader works just like "file" loader but it also embeds
180- // assets smaller than specified size as data URLs to avoid requests.
181- {
182- test : [ / \. b m p $ / , / \. g i f $ / , / \. j p e ? g $ / , / \. p n g $ / ] ,
183- loader : require . resolve ( 'url-loader' ) ,
184- options : {
185- limit : 10000 ,
186- name : 'static/media/[name].[hash:8].[ext]' ,
187- } ,
188- } ,
189- // Process JS with Babel.
190- {
191- test : / \. ( j s | j s x ) $ / ,
192- include : paths . appSrc ,
193- loader : require . resolve ( 'babel-loader' ) ,
194- options : {
195- // @remove -on-eject-begin
196- babelrc : false ,
197- presets : [ require . resolve ( 'babel-preset-react-app' ) ] ,
198- // @remove -on-eject-end
199- compact : true ,
200- } ,
201- } ,
202- // The notation here is somewhat confusing.
203- // "postcss" loader applies autoprefixer to our CSS.
204- // "css" loader resolves paths in CSS and adds assets as dependencies.
205- // "style" loader normally turns CSS into JS modules injecting <style>,
206- // but unlike in development configuration, we do something different.
207- // `ExtractTextPlugin` first applies the "postcss" and "css" loaders
208- // (second argument), then grabs the result CSS and puts it into a
209- // separate file in our build process. This way we actually ship
210- // a single CSS file in production instead of JS code injecting <style>
211- // tags. If you use code splitting, however, any async bundles will still
212- // use the "style" loader inside the async code so CSS from them won't be
213- // in the main CSS file.
214155 {
215- test : / \. c s s $ / ,
216- loader : ExtractTextPlugin . extract (
217- Object . assign (
218- {
219- fallback : require . resolve ( 'style-loader' ) ,
220- use : [
221- {
222- loader : require . resolve ( 'css-loader' ) ,
223- options : {
224- importLoaders : 1 ,
225- minimize : true ,
226- sourceMap : true ,
227- } ,
228- } ,
156+ // "oneOf" will traverse all following loaders until one will
157+ // match the requirements. When no loader matches it will fall
158+ // back to the "file" loader at the end of the loader list.
159+ oneOf : [
160+ // "url" loader works just like "file" loader but it also embeds
161+ // assets smaller than specified size as data URLs to avoid requests.
162+ {
163+ test : [ / \. b m p $ / , / \. g i f $ / , / \. j p e ? g $ / , / \. p n g $ / ] ,
164+ loader : require . resolve ( 'url-loader' ) ,
165+ options : {
166+ limit : 10000 ,
167+ name : 'static/media/[name].[hash:8].[ext]' ,
168+ } ,
169+ } ,
170+ // Process JS with Babel.
171+ {
172+ test : / \. ( j s | j s x ) $ / ,
173+ include : paths . appSrc ,
174+ loader : require . resolve ( 'babel-loader' ) ,
175+ options : {
176+ // @remove -on-eject-begin
177+ babelrc : false ,
178+ presets : [ require . resolve ( 'babel-preset-react-app' ) ] ,
179+ // @remove -on-eject-end
180+ compact : true ,
181+ } ,
182+ } ,
183+ // The notation here is somewhat confusing.
184+ // "postcss" loader applies autoprefixer to our CSS.
185+ // "css" loader resolves paths in CSS and adds assets as dependencies.
186+ // "style" loader normally turns CSS into JS modules injecting <style>,
187+ // but unlike in development configuration, we do something different.
188+ // `ExtractTextPlugin` first applies the "postcss" and "css" loaders
189+ // (second argument), then grabs the result CSS and puts it into a
190+ // separate file in our build process. This way we actually ship
191+ // a single CSS file in production instead of JS code injecting <style>
192+ // tags. If you use code splitting, however, any async bundles will still
193+ // use the "style" loader inside the async code so CSS from them won't be
194+ // in the main CSS file.
195+ {
196+ test : / \. c s s $ / ,
197+ loader : ExtractTextPlugin . extract (
198+ Object . assign (
229199 {
230- loader : require . resolve ( 'postcss-loader' ) ,
231- options : {
232- // Necessary for external CSS imports to work
233- // https://github.com/facebookincubator/create-react-app/issues/2677
234- ident : 'postcss' ,
235- plugins : ( ) => [
236- require ( 'postcss-flexbugs-fixes' ) ,
237- autoprefixer ( {
238- browsers : [
239- '>1%' ,
240- 'last 4 versions' ,
241- 'Firefox ESR' ,
242- 'not ie < 9' , // React doesn't support IE8 anyway
200+ fallback : require . resolve ( 'style-loader' ) ,
201+ use : [
202+ {
203+ loader : require . resolve ( 'css-loader' ) ,
204+ options : {
205+ importLoaders : 1 ,
206+ minimize : true ,
207+ sourceMap : true ,
208+ } ,
209+ } ,
210+ {
211+ loader : require . resolve ( 'postcss-loader' ) ,
212+ options : {
213+ // Necessary for external CSS imports to work
214+ // https://github.com/facebookincubator/create-react-app/issues/2677
215+ ident : 'postcss' ,
216+ plugins : ( ) => [
217+ require ( 'postcss-flexbugs-fixes' ) ,
218+ autoprefixer ( {
219+ browsers : [
220+ '>1%' ,
221+ 'last 4 versions' ,
222+ 'Firefox ESR' ,
223+ 'not ie < 9' , // React doesn't support IE8 anyway
224+ ] ,
225+ flexbox : 'no-2009' ,
226+ } ) ,
243227 ] ,
244- flexbox : 'no-2009' ,
245- } ) ,
246- ] ,
247- } ,
228+ } ,
229+ } ,
230+ ] ,
248231 } ,
249- ] ,
232+ extractTextPluginOptions
233+ )
234+ ) ,
235+ // Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
236+ } ,
237+ // "file" loader makes sure assets end up in the `build` folder.
238+ // When you `import` an asset, you get its filename.
239+ // This loader don't uses a "test" so it will catch all modules
240+ // that fall through the other loaders.
241+ {
242+ loader : require . resolve ( 'file-loader' ) ,
243+ // Exclude `js` files to keep "css" loader working as it injects
244+ // it's runtime that would otherwise processed through "file" loader.
245+ // Also exclude `html` and `json` extensions so they get processed
246+ // by webpacks internal loaders.
247+ exclude : [ / \. j s $ / , / \. h t m l $ / , / \. j s o n $ / ] ,
248+ options : {
249+ name : 'static/media/[name].[hash:8].[ext]' ,
250250 } ,
251- extractTextPluginOptions
252- )
253- ) ,
254- // Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
251+ } ,
252+ // ** STOP ** Are you adding a new loader?
253+ // Make sure to add the new loader(s) before the "file" loader.
254+ ] ,
255255 } ,
256- // ** STOP ** Are you adding a new loader?
257- // Remember to add the new extension(s) to the "file" loader exclusion list.
258256 ] ,
259257 } ,
260258 plugins : [
0 commit comments