-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
75 changed files
with
12,795 additions
and
2,436 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import esbuild from "esbuild"; | ||
import process from "process"; | ||
import builtins from 'builtin-modules' | ||
import fs from 'fs' | ||
import { copy } from 'esbuild-plugin-copy'; | ||
import * as dotenv from 'dotenv' | ||
dotenv.config() | ||
|
||
const banner = | ||
`/* | ||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD | ||
if you want to view the source, please visit the github repository of this plugin | ||
*/ | ||
`; | ||
|
||
const demo = (process.argv[2] === 'demo'); | ||
const prod = (process.argv[2] === 'production'); | ||
|
||
let renamePlugin = { | ||
name: 'rename-styles', | ||
setup(build) { | ||
build.onEnd(() => { | ||
const { outfile } = build.initialOptions; | ||
const outcss = outfile.replace(/\.js$/, '.css'); | ||
const fixcss = outfile.replace(/main\.js$/, 'styles.css'); | ||
if (fs.existsSync(outcss)) { | ||
console.log('Renaming', outcss, 'to', fixcss); | ||
fs.renameSync(outcss, fixcss); | ||
} | ||
}); | ||
}, | ||
}; | ||
|
||
|
||
const outputDir = prod ? process.env.buildDir : demo ? process.env.demoDir : process.env.devDir | ||
esbuild.build({ | ||
banner: { | ||
js: banner, | ||
}, | ||
entryPoints: ['main.ts'], | ||
bundle: true, | ||
external: [ | ||
'obsidian', | ||
'electron', | ||
'@codemirror/autocomplete', | ||
'@codemirror/collab', | ||
'@codemirror/commands', | ||
'@codemirror/language', | ||
'@codemirror/lint', | ||
'@codemirror/search', | ||
'@codemirror/state', | ||
'@codemirror/view', | ||
...builtins], | ||
format: 'cjs', | ||
watch: !prod, | ||
target: 'es2018', | ||
logLevel: "info", | ||
sourcemap: prod ? false : 'inline', | ||
treeShaking: true, | ||
outfile: outputDir+'/main.js', | ||
plugins: [renamePlugin, | ||
...(prod ? [copy({ | ||
resolveFrom: 'cwd', | ||
assets: { | ||
from: ['./manifest.json'], | ||
to: [outputDir+'/manifest.json'], | ||
}, | ||
})] : []), | ||
], | ||
}).catch(() => process.exit(1)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare module '*.css'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.