@@ -95,10 +95,25 @@ export const prepare = async (app, config) => {
95
95
96
96
app . static = await prepareMetaFiles ( app , config )
97
97
98
- let staticExists = false
99
98
try {
100
- await fs . stat ( config . DIR . STATIC )
101
- staticExists = true
99
+ let staticDirs = config . DIR . STATIC
100
+ if ( ! is . array ( staticDirs ) ) {
101
+ staticDirs = [ staticDirs ]
102
+ }
103
+
104
+ await Promise . all ( staticDirs . map ( async dir => {
105
+ const staticFiles = await fs . getFiles ( dir )
106
+
107
+ if ( ! is . empty ( staticFiles ) ) {
108
+ const staticPromises = staticFiles . map ( async f => {
109
+ const name = f . replace ( dir , '' )
110
+ // TODO: use streams here
111
+ app . static [ name ] = await fs . readFile ( f )
112
+ } )
113
+
114
+ await Promise . all ( staticPromises )
115
+ }
116
+ } ) )
102
117
} catch ( e ) {
103
118
// it's fine if the static dir does not exist,
104
119
// but all other errors will throw.
@@ -107,19 +122,6 @@ export const prepare = async (app, config) => {
107
122
}
108
123
}
109
124
110
- if ( staticExists ) {
111
- const staticFiles = await fs . getFiles ( config . DIR . STATIC )
112
- if ( ! is . empty ( staticFiles ) ) {
113
- const staticPromises = staticFiles . map ( async f => {
114
- const name = f . replace ( config . DIR . STATIC , '' )
115
- // TODO: use streams here
116
- app . static [ name ] = await fs . readFile ( f )
117
- } )
118
-
119
- await Promise . all ( staticPromises )
120
- }
121
- }
122
-
123
125
app . style = await prepareThemes ( app , config )
124
126
125
127
// mutates app
0 commit comments