@pictogrammers/element-esbuild 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { pathToFileURL } from 'node:url';
3
+ import { fileURLToPath, pathToFileURL } from 'node:url';
4
4
  import { build } from 'esbuild';
5
5
 
6
6
  import { htmlDependentsPlugin } from '../scripts/htmlDependentsPlugin.ts';
7
7
  import { rebuildNotifyPlugin } from '../scripts/rebuildNotifyPlugin.ts';
8
8
  import { fileExists } from '../scripts/fileExists.ts';
9
9
  import { copyFile } from 'node:fs/promises';
10
- import { join } from 'node:path';
10
+ import { dirname, join } from 'node:path';
11
11
  import { playgroundPlugin } from '../scripts/playgroundPlugin.ts';
12
12
 
13
13
  const plugins = [htmlDependentsPlugin, rebuildNotifyPlugin];
@@ -16,6 +16,9 @@ const entryPoints: string[] = [];
16
16
  const green = (text: string) => `\x1b[32m${text}\x1b[0m`;
17
17
  const red = (text: string) => `\x1b[31m${text}\x1b[0m`;
18
18
 
19
+ const __filename = fileURLToPath(import.meta.url);
20
+ const __dirname = dirname(__filename);
21
+ const defaultDir = join(__dirname, '..', 'default');
19
22
  const indexFile = 'index.html';
20
23
  const distDir = 'dist';
21
24
  const srcDir = 'src';
@@ -70,6 +73,19 @@ build({
70
73
  if (await fileExists(join(rootDir, distDir, indexFile))) {
71
74
  await copyFile(join(rootDir, distDir, indexFile), join(rootDir, buildDir, indexFile));
72
75
  }
76
+ // Handle favicon.svg
77
+ const faviconSvg = 'favicon.svg';
78
+ if (await fileExists(join(rootDir, srcDir, faviconSvg))) {
79
+ await copyFile(
80
+ join(rootDir, srcDir, faviconSvg),
81
+ join(rootDir, buildDir, faviconSvg)
82
+ );
83
+ } else {
84
+ await copyFile(
85
+ join(defaultDir, faviconSvg),
86
+ join(rootDir, buildDir, faviconSvg)
87
+ );
88
+ }
73
89
  }).catch((err) => {
74
90
  process.stderr.write(err.stderr);
75
91
  process.exit(1);
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  import { context } from 'esbuild';
4
4
  import chokidar from 'chokidar';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pictogrammers/element-esbuild",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "description": "Element esbuild",
6
6
  "homepage": "https://github.com/Pictogrammers/Element-esbuild#readme",