Skip to content

Commit 30df2f9

Browse files
committed
Get routes from paths to static
1 parent 33e531c commit 30df2f9

File tree

1 file changed

+11
-27
lines changed

1 file changed

+11
-27
lines changed

gulpfile.js

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const PATHS_TO_STATIC = [
2727
`${PATH_TO_SOURCE}fonts/**/*.{woff2,woff}`,
2828
`${PATH_TO_SOURCE}*.ico`,
2929
`${PATH_TO_SOURCE}*.webmanifest`,
30-
`${PATH_TO_SOURCE}favicons/*.{png,svg}`,
30+
`${PATH_TO_SOURCE}favicons/**/*.{png,svg}`,
3131
`${PATH_TO_SOURCE}vendor/**/*`,
3232
`${PATH_TO_SOURCE}images/**/*`,
3333
`!${PATH_TO_SOURCE}images/icons/**/*`,
@@ -124,36 +124,20 @@ export function copyStatic () {
124124
}
125125

126126
export function startServer () {
127+
const serveStatic = PATHS_TO_STATIC
128+
.filter((path) => path.startsWith('!') === false)
129+
.map((path) => {
130+
const dir = path.replace(/\*\*(.*)/, '');
131+
const route = dir.replace(PATH_TO_SOURCE, '/')
132+
133+
return { route, dir };
134+
});
135+
127136
server.init({
128137
server: {
129138
baseDir: PATH_TO_DIST
130139
},
131-
serveStatic: [
132-
{
133-
route: '/fonts',
134-
dir: `${PATH_TO_SOURCE}fonts`,
135-
},
136-
{
137-
route: '/*.ico',
138-
dir: `${PATH_TO_SOURCE}*.ico`,
139-
},
140-
{
141-
route: '/*.webmanifest',
142-
dir: `${PATH_TO_SOURCE}*.webmanifest`,
143-
},
144-
{
145-
route: '/favicons',
146-
dir: `${PATH_TO_SOURCE}favicons`,
147-
},
148-
{
149-
route: '/vendor',
150-
dir: `${PATH_TO_SOURCE}vendor`,
151-
},
152-
{
153-
route: '/images',
154-
dir: `${PATH_TO_SOURCE}images`,
155-
},
156-
],
140+
serveStatic,
157141
cors: true,
158142
notify: false,
159143
ui: false,

0 commit comments

Comments
 (0)