1- const path = require ( 'path' ) // eslint-disable-line
1+ /* eslint-disable @typescript-eslint/no-var-requires */
2+ const path = require ( 'path' )
3+ const { addBabelPreset, addBabelPlugin, addWebpackModuleRule} = require ( 'customize-cra' )
24
35module . exports = function override ( config ) {
4- config . module . rules . push ( {
6+ addWebpackModuleRule ( {
57test :/ \. ( w o f f ( 2 ) ? | t t f | e o t | s v g ) ( \? v = \d + \. \d + \. \d + ) ? $ / ,
68use :[
79{
@@ -12,34 +14,19 @@ module.exports = function override(config) {
1214} ,
1315} ,
1416] ,
15- } )
17+ } ) ( config )
1618
17- config . module . rules . push ( {
18- test :/ \. ( t s | t s x ) $ / ,
19- loader :require . resolve ( 'babel-loader' ) ,
20- options :{
21- plugins :[
22- // load css for@alifd /next components
23- [
24- 'babel-plugin-import' ,
25- {
26- libraryName :'@alifd/next' ,
27- style :true ,
28- } ,
29- ] ,
30- ] ,
31- presets :[
32- // react-app
33- [ 'react-app' , { flow :false , typescript :true } ] ,
34- // allow emotion css prop on html
35- [ '@emotion/babel-preset-css-prop' ] ,
36- ] ,
19+ // load@alifd /next component css
20+ addBabelPlugin ( [
21+ 'babel-plugin-import' ,
22+ {
23+ libraryName :'@alifd/next' ,
24+ style :true ,
3725} ,
38- } )
26+ ] ) ( config )
3927
40- config . resolve . extensions . push ( '.ts' , '.tsx' )
41-
42- config . resolve . modules = [ 'node_modules' , path . resolve ( __dirname , './src' ) ]
28+ // setup emotion styles
29+ addBabelPreset ( '@emotion/babel-preset-css-prop' ) ( config )
4330
4431return config
4532}