-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathesbuild.js
44 lines (34 loc) · 1.1 KB
/
esbuild.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
import esbuild from "esbuild";
import { sassPlugin } from 'esbuild-sass-plugin';
import path from 'path';
import fs from 'fs';
import dotenv from "dotenv";
dotenv.config();
const dir = './SCSS/snippets';
const files = fs.readdirSync(dir)
const flags = process.argv;
const options = {
production: flags.includes('production'),
snippet: flags.includes('snippet'),
development: flags.includes('development'),
}
function createSnippetArray () {
return files.map(file => {
return path.join(dir,file)
})
}
const testingVaultPath = path.join(
process.env.TESTING_VAULT_PATH,
".obsidian",
"themes",
);
const outOptions = options.production ? {outfile: "./obsidian.css"} : options.snippet ? {outdir: "./snippets"} : {outdir: testingVaultPath};
const entrySettings = options.production ? ["./SCSS/Spectrum.scss"] : options.snippet ? createSnippetArray() : {"spectrum-testing": "./SCSS/Spectrum.scss"};
esbuild.build({
entryPoints: entrySettings,
...outOptions,
minify: options.production,
plugins: [sassPlugin()],
watch: options.development,
treeShaking: options.production,
})