Merge b5bd130a6e
into bfa0145644
This commit is contained in:
commit
1bd7d3111a
|
@ -8,9 +8,10 @@
|
||||||
# npm
|
# npm
|
||||||
node_modules
|
node_modules
|
||||||
|
|
||||||
# Don't include the compiled main.js file in the repo.
|
# Don't include the build artifacts in the repo.
|
||||||
# They should be uploaded to GitHub releases instead.
|
# They should be uploaded to GitHub releases instead.
|
||||||
main.js
|
main.js
|
||||||
|
dist/
|
||||||
|
|
||||||
# Exclude sourcemaps
|
# Exclude sourcemaps
|
||||||
*.map
|
*.map
|
||||||
|
|
|
@ -1,21 +1,24 @@
|
||||||
|
import process from "node:process";
|
||||||
|
import path from "node:path";
|
||||||
|
import { copyFileSync } from "node:fs";
|
||||||
|
|
||||||
import esbuild from "esbuild";
|
import esbuild from "esbuild";
|
||||||
import process from "process";
|
|
||||||
import builtins from "builtin-modules";
|
import builtins from "builtin-modules";
|
||||||
|
|
||||||
const banner =
|
const banner = `/*
|
||||||
`/*
|
|
||||||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||||||
if you want to view the source, please visit the github repository of this plugin
|
if you want to view the source, please visit the github repository of this plugin
|
||||||
*/
|
*/
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const prod = (process.argv[2] === "production");
|
const prod = process.argv[2] === "production";
|
||||||
|
|
||||||
const context = await esbuild.context({
|
const buildOptions = {
|
||||||
banner: {
|
banner: {
|
||||||
js: banner,
|
js: banner,
|
||||||
},
|
},
|
||||||
entryPoints: ["main.ts"],
|
entryPoints: ["main.ts", "styles.css"],
|
||||||
|
outdir: "dist",
|
||||||
bundle: true,
|
bundle: true,
|
||||||
external: [
|
external: [
|
||||||
"obsidian",
|
"obsidian",
|
||||||
|
@ -31,17 +34,33 @@ const context = await esbuild.context({
|
||||||
"@lezer/common",
|
"@lezer/common",
|
||||||
"@lezer/highlight",
|
"@lezer/highlight",
|
||||||
"@lezer/lr",
|
"@lezer/lr",
|
||||||
...builtins],
|
...builtins,
|
||||||
|
],
|
||||||
format: "cjs",
|
format: "cjs",
|
||||||
target: "es2018",
|
target: "es2018",
|
||||||
logLevel: "info",
|
logLevel: "info",
|
||||||
sourcemap: prod ? false : "inline",
|
sourcemap: prod ? false : "inline",
|
||||||
treeShaking: true,
|
treeShaking: true,
|
||||||
outfile: "main.js",
|
};
|
||||||
});
|
|
||||||
|
const context = await esbuild.context(buildOptions);
|
||||||
|
|
||||||
if (prod) {
|
if (prod) {
|
||||||
await context.rebuild();
|
await context.rebuild();
|
||||||
|
/**
|
||||||
|
* If there is a new version number, copy it to the dist folder
|
||||||
|
*/
|
||||||
|
if (process.env.npm_new_version) {
|
||||||
|
const manifestJsonSrc = path.join(process.cwd(), "manifest.json");
|
||||||
|
const manifestJsonDist = path.join(
|
||||||
|
process.cwd(),
|
||||||
|
buildOptions.outdir,
|
||||||
|
"manifest.json"
|
||||||
|
);
|
||||||
|
|
||||||
|
// Copy the manifest.json file over to the dist folder
|
||||||
|
copyFileSync(manifestJsonSrc, manifestJsonDist);
|
||||||
|
}
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
} else {
|
} else {
|
||||||
await context.watch();
|
await context.watch();
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -6,7 +6,7 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "node esbuild.config.mjs",
|
"dev": "node esbuild.config.mjs",
|
||||||
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
|
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
|
||||||
"version": "node version-bump.mjs && git add manifest.json versions.json"
|
"version": "node version-bump.mjs && npm run build && git add manifest.json versions.json"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
|
|
Loading…
Reference in New Issue