-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
esbuild.config.mjs
52 lines (44 loc) · 1.48 KB
/
esbuild.config.mjs
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
/**
* Thank you to @valentine195 for not only setting my first esbuild config,
* but also taking the time to explain each step.
*/
import esbuild from "esbuild";
import process from "process";
import { config } from "dotenv";
import { sassPlugin } from "esbuild-sass-plugin";
import time from "esbuild-plugin-time";
import { readFileSync } from "fs";
config();
const prod = process.argv[2] === "production";
/** This determines where the output file goes.
* npm run dev will put it in OUTDIR specified in your .env
* npm run build will place it in the build directory in this repository.
*/
const dir = prod ? "./" : process.env.OUTDIR;
/** Paths for final file */
const fileProd = `${dir}/theme.css`;
const fileDev = `${dir}/SanctumDev.css`
/** readFileSync reads the file data in a string. */
const license = readFileSync("./src/css/license.css", "utf8");
const hub = readFileSync("./src/css/plugin-compatibility.css", "utf8");
esbuild
.build({
/** Entry point should be where everything is imported into. */
entryPoints: ["src/scss/index.scss"],
/** Banner places the content at the beginning of the bundled file. */
banner: {
css: license
},
/** Footer places the content at the end of the bundled file. */
footer: {
css: hub
},
/** npm run dev will watch for file changes and rebuild instantly. */
watch: !prod,
logLevel: "info",
bundle: true,
minify: false,
outfile: prod ? fileProd : fileDev,
plugins: [sassPlugin(), time()]
})
.catch(() => process.exit(1));