@@ -28,11 +28,37 @@ const tsAlias = _(tspathMountMapping)
28
28
// .filter(_.isArray)
29
29
// );
30
30
31
+ // ant design 相关
32
+ // Copy from Client/build/config/webpack.base.config.js
33
+ const modifyVars = _ . toPairs ( {
34
+ 'primary-color' : '#8C6244' ,
35
+ 'error-color' : '#e44a4c' ,
36
+ 'text-selection-bg' : '#1890ff' ,
37
+ } )
38
+ . map ( ( [ key , value ] ) => `--modify-var="${ key } =${ value } "` )
39
+ . join ( ' ' ) ;
40
+ const antdLessCompile = `${ path . resolve (
41
+ __dirname ,
42
+ './node_modules/.bin/lessc'
43
+ ) } ${ path . resolve (
44
+ __dirname ,
45
+ './node_modules/antd/dist/antd.less'
46
+ ) } ${ path . resolve (
47
+ __dirname ,
48
+ './public/.snowpack/antd.css'
49
+ ) } --js ${ modifyVars } `;
50
+ const antdDarkLessCompile = `${ path . resolve (
51
+ __dirname ,
52
+ './node_modules/.bin/lessc'
53
+ ) } ${ path . resolve (
54
+ __dirname ,
55
+ './node_modules/antd/dist/antd.dark.less'
56
+ ) } ${ path . resolve (
57
+ __dirname ,
58
+ './public/.snowpack/antd.dark.css'
59
+ ) } --js ${ modifyVars } `;
60
+
31
61
module . exports = {
32
- // extends: '@snowpack/app-scripts-react',
33
- install : [
34
- 'antd/dist/antd.dark.css'
35
- ] ,
36
62
exclude : [
37
63
'**/node_modules/**/*' ,
38
64
'**/__tests__/*' ,
@@ -55,6 +81,8 @@ module.exports = {
55
81
'@src' : './src/' ,
56
82
} ,
57
83
plugins : [
84
+ [ '@snowpack/plugin-run-script' , { name : 'antd compile' , cmd : antdLessCompile } ] ,
85
+ [ '@snowpack/plugin-run-script' , { name : 'antd dark mode compile' , cmd : antdDarkLessCompile } ] ,
58
86
'@snowpack/plugin-typescript' ,
59
87
'@snowpack/plugin-sass' ,
60
88
'snowpack-plugin-less' ,
@@ -86,17 +114,15 @@ module.exports = {
86
114
} ) } ;`,
87
115
} ,
88
116
89
- // 这里是临时解决方案
90
- // https://github.com/snowpackjs/snowpack/discussions/1360
91
117
{
92
118
from : 'import "antd/dist/antd.dark.less";' ,
93
- to : 'import "antd/dist /antd.dark.css"; ' ,
119
+ to : 'import "/.snowpack /antd.dark.css"' ,
94
120
} ,
95
121
{
96
122
file : require . resolve ( './src/web/assets/css/iconfont.css' ) ,
97
123
from : / \. \. \/ f o n t s \/ i c o n f o n t / g,
98
124
to : '/fonts/iconfont' ,
99
- }
125
+ } ,
100
126
] ,
101
127
} ,
102
128
] ,
@@ -111,6 +137,6 @@ module.exports = {
111
137
port : 8089 ,
112
138
out : '.snowpack' ,
113
139
output : 'stream' ,
114
- hmrErrorOverlay : false
140
+ hmrErrorOverlay : false ,
115
141
} ,
116
142
} ;
0 commit comments