-
Notifications
You must be signed in to change notification settings - Fork 0
/
preact.config.js
31 lines (26 loc) · 770 Bytes
/
preact.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import path from 'path';
import { lstatSync, readdirSync } from 'fs';
export default (config, env, helpers) => {
const enableAbsoluteImport = () => {
const isDirectory = source => lstatSync(source).isDirectory();
const getDirectories = source =>
readdirSync(source)
.map(name => path.join(source, name))
.filter(isDirectory);
getDirectories('src/').map(dir => {
config.resolve.alias[dir.replace('src/', '')] = path.resolve(__dirname, dir);
});
};
const enableDevServerProxy = () => {
config.devServer.proxy = [
{
path: '/api',
target: `http://localhost:${env.pkg.application.server.port}`,
},
];
};
enableAbsoluteImport();
if (env.dev) {
enableDevServerProxy();
}
};