-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconfig.js
65 lines (45 loc) · 1.39 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import restricttonode from "./libs/restrict-to-node.js";
import fs from "fs";
import path from "path";
import env from "./libs/dotenv.js";
import * as dotenv from "dotenv"; // see https://github.com/motdotla/dotenv#how-do-i-use-dotenv-with-import
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
restricttonode(__filename);
const root = path.resolve(__dirname);
const vardir = path.resolve(root, "var");
// relative path to public server directory
const output = path.resolve(root, "public", "dist");
const node_modules = path.join(root, "node_modules");
const app = path.resolve(root, "pages");
const override = path.resolve(root, "override");
const envfile = path.resolve(".", ".env");
if (!fs.existsSync(envfile)) {
throw new Error(`File ${envfile} doesn't exist`);
}
dotenv.config({
path: envfile,
});
export default (mode) => ({
// just name for this project, it's gonna show up in some places
name: env("PROJECT_NAME"),
root,
app,
node_modules,
vardir,
output,
resolve: [
// where to search by require and files to watch
app,
override,
"node_modules", // https://github.com/ReactTraining/react-router/issues/6201#issuecomment-403291934
],
js: {
entries: [
// looks for *.entry.{js|jsx} - watch only on files *.entry.{js|jsx}
app,
// ...
],
},
});