mirror of
https://github.com/anotherlusitano/SpectrumPlus.git
synced 2026-07-22 04:10:27 +00:00
49 lines
1.2 KiB
JavaScript
49 lines
1.2 KiB
JavaScript
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)
|
|
})
|
|
}
|
|
|
|
if (process.env.TESTING_VAULT_PATH === undefined) {
|
|
console.error("TESTING_VAULT_PATH is not set in the environment variables.");
|
|
process.exit(1);
|
|
}
|
|
|
|
const testingVaultPath = path.join(
|
|
process.env.TESTING_VAULT_PATH,
|
|
".obsidian",
|
|
"themes",
|
|
);
|
|
|
|
const outOptions = options.production ? {outfile: "./theme.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,
|
|
})
|
|
|