File tree 7 files changed +74
-34
lines changed
7 files changed +74
-34
lines changed Original file line number Diff line number Diff line change @@ -9,14 +9,32 @@ const themeVariables = lessToJS(
9
9
fs . readFileSync ( path . resolve ( __dirname , './assets/antd-custom.less' ) , 'utf8' )
10
10
)
11
11
12
- // fix: prevents error when .less files are required by node
13
- if ( typeof require !== 'undefined' ) {
14
- require . extensions [ '.less' ] = file => { }
15
- }
16
-
17
12
module . exports = withLess ( {
18
13
lessLoaderOptions : {
19
14
javascriptEnabled : true ,
20
15
modifyVars : themeVariables , // make your antd custom effective
21
16
} ,
17
+ webpack : ( config , { isServer } ) => {
18
+ if ( isServer ) {
19
+ const antStyles = / a n t d \/ .* ?\/ s t y l e .* ?/
20
+ const origExternals = [ ...config . externals ]
21
+ config . externals = [
22
+ ( context , request , callback ) => {
23
+ if ( request . match ( antStyles ) ) return callback ( )
24
+ if ( typeof origExternals [ 0 ] === 'function' ) {
25
+ origExternals [ 0 ] ( context , request , callback )
26
+ } else {
27
+ callback ( )
28
+ }
29
+ } ,
30
+ ...( typeof origExternals [ 0 ] === 'function' ? [ ] : origExternals ) ,
31
+ ]
32
+
33
+ config . module . rules . unshift ( {
34
+ test : antStyles ,
35
+ use : 'null-loader' ,
36
+ } )
37
+ }
38
+ return config
39
+ } ,
22
40
} )
Original file line number Diff line number Diff line change 13
13
"less" : " 3.0.4" ,
14
14
"less-vars-to-js" : " 1.3.0" ,
15
15
"next" : " latest" ,
16
+ "null-loader" : " 2.0.0" ,
16
17
"react" : " ^16.7.0" ,
17
18
"react-dom" : " ^16.7.0"
18
19
},
Original file line number Diff line number Diff line change 1
1
/* eslint-disable */
2
2
const withCss = require ( '@zeit/next-css' )
3
3
4
- // fix: prevents error when .css files are required by node
5
- if ( typeof require !== 'undefined' ) {
6
- require . extensions [ '.css' ] = file => { }
7
- }
4
+ module . exports = withCss ( {
5
+ webpack : ( config , { isServer } ) => {
6
+ if ( isServer ) {
7
+ const antStyles = / a n t d \/ .* ?\/ s t y l e \/ c s s .* ?/
8
+ const origExternals = [ ...config . externals ]
9
+ config . externals = [
10
+ ( context , request , callback ) => {
11
+ if ( request . match ( antStyles ) ) return callback ( )
12
+ if ( typeof origExternals [ 0 ] === 'function' ) {
13
+ origExternals [ 0 ] ( context , request , callback )
14
+ } else {
15
+ callback ( )
16
+ }
17
+ } ,
18
+ ...( typeof origExternals [ 0 ] === 'function' ? [ ] : origExternals ) ,
19
+ ]
8
20
9
- module . exports = withCss ( )
21
+ config . module . rules . unshift ( {
22
+ test : antStyles ,
23
+ use : 'null-loader' ,
24
+ } )
25
+ }
26
+ return config
27
+ } ,
28
+ } )
Original file line number Diff line number Diff line change 11
11
"antd" : " ^3.9.2" ,
12
12
"babel-plugin-import" : " ^1.9.1" ,
13
13
"next" : " latest" ,
14
+ "null-loader" : " 2.0.0" ,
14
15
"react" : " ^16.7.0" ,
15
16
"react-dom" : " ^16.7.0"
16
17
},
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
const withCSS = require ( '@zeit/next-css' )
2
2
3
- // fix: prevents error when .css files are required by node
4
- if ( typeof require !== 'undefined' ) {
5
- // eslint-disable-next-line
6
- require . extensions [ '.css' ] = file => { }
7
- }
3
+ module . exports = withCSS ( {
4
+ webpack : ( config , { isServer } ) => {
5
+ if ( isServer ) {
6
+ const antStyles = / a n t d - m o b i l e \/ .* ?\/ s t y l e .* ?/
7
+ const origExternals = [ ...config . externals ]
8
+ config . externals = [
9
+ ( context , request , callback ) => {
10
+ if ( request . match ( antStyles ) ) return callback ( )
11
+ if ( typeof origExternals [ 0 ] === 'function' ) {
12
+ origExternals [ 0 ] ( context , request , callback )
13
+ } else {
14
+ callback ( )
15
+ }
16
+ } ,
17
+ ...( typeof origExternals [ 0 ] === 'function' ? [ ] : origExternals )
18
+ ]
8
19
9
- module . exports = withCSS ( )
20
+ config . module . rules . unshift ( {
21
+ test : antStyles ,
22
+ use : 'null-loader'
23
+ } )
24
+ }
25
+ return config
26
+ }
27
+ } )
Original file line number Diff line number Diff line change 6
6
"antd-mobile" : " 2.2.5" ,
7
7
"babel-plugin-import" : " ^1.2.1" ,
8
8
"next" : " latest" ,
9
+ "null-loader" : " 2.0.0" ,
9
10
"react" : " ^16.7.0" ,
10
11
"react-dom" : " ^16.7.0"
11
12
},
You can’t perform that action at this time.
0 commit comments