mirror of
https://github.com/stracker-phil/obsidian-mention-things.git
synced 2026-07-22 05:43:27 +00:00
🔨 Update dev configuration
This commit is contained in:
parent
221583397a
commit
1c9ca03dec
3 changed files with 57 additions and 35 deletions
|
|
@ -1,3 +1,3 @@
|
|||
node_modules/
|
||||
|
||||
main.js
|
||||
dist/
|
||||
|
|
|
|||
|
|
@ -1,45 +1,73 @@
|
|||
import esbuild from "esbuild";
|
||||
import process from "process";
|
||||
import builtins from "builtin-modules";
|
||||
import fs from "fs-extra";
|
||||
import esbuild from 'esbuild';
|
||||
import process from 'process';
|
||||
import builtins from 'builtin-modules';
|
||||
import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
|
||||
const banner =
|
||||
`/*
|
||||
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 prod = (process.argv[2] === "production");
|
||||
const prod = (process.argv[2] === 'production');
|
||||
|
||||
// Plugin to copy additional files
|
||||
const copyFilesToDist = {
|
||||
name: 'copy-files',
|
||||
setup(build) {
|
||||
build.onEnd(async (result) => {
|
||||
if (result.errors.length > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const distDir = path.join(process.cwd(), 'dist');
|
||||
|
||||
await fs.copy('manifest.json', path.join(distDir, 'manifest.json'));
|
||||
|
||||
if (await fs.pathExists('styles.css')) {
|
||||
await fs.copy('styles.css', path.join(distDir, 'styles.css'));
|
||||
}
|
||||
|
||||
if (await fs.pathExists('resources')) {
|
||||
await fs.copy('resources', path.join(distDir, 'resources'));
|
||||
}
|
||||
|
||||
console.log('Copied additional files to /dist folder.');
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
const context = await esbuild.context({
|
||||
banner: {
|
||||
js: banner,
|
||||
},
|
||||
entryPoints: ["src/main.ts"],
|
||||
entryPoints: ['src/main.ts'],
|
||||
bundle: true,
|
||||
external: [
|
||||
"obsidian",
|
||||
"electron",
|
||||
"@codemirror/autocomplete",
|
||||
"@codemirror/collab",
|
||||
"@codemirror/commands",
|
||||
"@codemirror/language",
|
||||
"@codemirror/lint",
|
||||
"@codemirror/search",
|
||||
"@codemirror/state",
|
||||
"@codemirror/view",
|
||||
"@lezer/common",
|
||||
"@lezer/highlight",
|
||||
"@lezer/lr",
|
||||
...builtins],
|
||||
format: "cjs",
|
||||
target: "es2018",
|
||||
logLevel: "info",
|
||||
sourcemap: prod ? false : "inline",
|
||||
'obsidian',
|
||||
'electron',
|
||||
'@codemirror/autocomplete',
|
||||
'@codemirror/collab',
|
||||
'@codemirror/commands',
|
||||
'@codemirror/language',
|
||||
'@codemirror/lint',
|
||||
'@codemirror/search',
|
||||
'@codemirror/state',
|
||||
'@codemirror/view',
|
||||
'@lezer/common',
|
||||
'@lezer/highlight',
|
||||
'@lezer/lr',
|
||||
...builtins,
|
||||
],
|
||||
format: 'cjs',
|
||||
target: 'es2018',
|
||||
logLevel: 'info',
|
||||
sourcemap: prod ? false : 'inline',
|
||||
treeShaking: true,
|
||||
outdir: "dist",
|
||||
outdir: 'dist',
|
||||
minify: prod,
|
||||
plugins: [copyFilesToDist],
|
||||
});
|
||||
|
||||
if (prod) {
|
||||
|
|
@ -48,9 +76,3 @@ if (prod) {
|
|||
} else {
|
||||
await context.watch();
|
||||
}
|
||||
|
||||
// Copy additional files to dist folder
|
||||
fs.copySync("manifest.json", "dist/manifest.json");
|
||||
if (fs.existsSync("resources")) {
|
||||
fs.copySync("resources", "dist/resources");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,6 @@
|
|||
]
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts"
|
||||
"src/**/*.ts"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue