orga-build 0.1.1 → 0.1.2
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.
- package/lib/esbuild/build.d.ts.map +1 -1
- package/lib/esbuild/build.js +27 -3
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["build.js"],"names":[],"mappings":"AAWA;;GAEG;AACH,uDAFW,OAAO,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["build.js"],"names":[],"mappings":"AAWA;;GAEG;AACH,uDAFW,OAAO,cAAc,EAAE,MAAM,iBA2MvC;AAqCD;;GAEG;AACH,2BAFW,OAAO,IAAI,EAAE,QAAQ,iBAI/B"}
|
package/lib/esbuild/build.js
CHANGED
|
@@ -39,12 +39,19 @@ export async function build({ outDir = 'dir', preBuild = [], postBuild = [] }) {
|
|
|
39
39
|
src.components.push(file)
|
|
40
40
|
return
|
|
41
41
|
}
|
|
42
|
+
// ignore other files starting with `_` or `.`
|
|
43
|
+
if (match(fileName, /(^_|^\.)/)) {
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
|
|
42
47
|
if (match(fileName, /\.(org)$/, /\.(j|t)sx$/)) {
|
|
43
48
|
src.pages.push(file)
|
|
44
49
|
return
|
|
45
50
|
}
|
|
46
51
|
})
|
|
47
52
|
|
|
53
|
+
const esbuildOutDir = '.orga-build'
|
|
54
|
+
|
|
48
55
|
const result = await esbuild.build({
|
|
49
56
|
entryPoints: [
|
|
50
57
|
...Object.values(src.layouts),
|
|
@@ -60,9 +67,10 @@ export async function build({ outDir = 'dir', preBuild = [], postBuild = [] }) {
|
|
|
60
67
|
// jsxFragment: 'React.Fragment',
|
|
61
68
|
jsx: 'automatic',
|
|
62
69
|
// write: false,
|
|
63
|
-
outdir:
|
|
70
|
+
outdir: esbuildOutDir,
|
|
64
71
|
// splitting: true,
|
|
65
72
|
metafile: true,
|
|
73
|
+
assetNames: '[name]-[hash]',
|
|
66
74
|
plugins: [
|
|
67
75
|
esbuildOrga({
|
|
68
76
|
reorgRehypeOptions: {
|
|
@@ -81,7 +89,11 @@ export async function build({ outDir = 'dir', preBuild = [], postBuild = [] }) {
|
|
|
81
89
|
// external: ['react/jsx-runtime'],
|
|
82
90
|
loader: {
|
|
83
91
|
'.jsx': 'jsx',
|
|
84
|
-
'.tsx': 'tsx'
|
|
92
|
+
'.tsx': 'tsx',
|
|
93
|
+
'.png': 'file',
|
|
94
|
+
'.jpg': 'file',
|
|
95
|
+
'.jpeg': 'file',
|
|
96
|
+
'.webp': 'file'
|
|
85
97
|
}
|
|
86
98
|
})
|
|
87
99
|
|
|
@@ -105,7 +117,15 @@ export async function build({ outDir = 'dir', preBuild = [], postBuild = [] }) {
|
|
|
105
117
|
let map = {}
|
|
106
118
|
// iterate over results to get layout and components
|
|
107
119
|
for (const [file, meta] of Object.entries(result.metafile.outputs)) {
|
|
108
|
-
if (!meta.entryPoint)
|
|
120
|
+
if (!meta.entryPoint) {
|
|
121
|
+
// copy assets
|
|
122
|
+
const relPath = path.relative(esbuildOutDir, file)
|
|
123
|
+
const to = path.join(cwd, path.join(outDir, relPath))
|
|
124
|
+
await fs.mkdir(path.dirname(to), { recursive: true })
|
|
125
|
+
await fs.copyFile(file, to)
|
|
126
|
+
continue
|
|
127
|
+
}
|
|
128
|
+
|
|
109
129
|
const fullSrc = path.join(cwd, meta.entryPoint)
|
|
110
130
|
// get components
|
|
111
131
|
if (src.components.includes(fullSrc)) {
|
|
@@ -204,6 +224,7 @@ async function walk(dirPath, callback) {
|
|
|
204
224
|
const queue = [dirPath]
|
|
205
225
|
|
|
206
226
|
const ignore = [/^\./, /node_modules/]
|
|
227
|
+
const ignoreDirs = [/^_/, /^\./, /node_modules/]
|
|
207
228
|
|
|
208
229
|
while (queue.length > 0) {
|
|
209
230
|
const currentPath = queue.shift()
|
|
@@ -218,6 +239,9 @@ async function walk(dirPath, callback) {
|
|
|
218
239
|
const stats = await fs.stat(filePath)
|
|
219
240
|
|
|
220
241
|
if (stats.isDirectory()) {
|
|
242
|
+
if (match(file, ...ignoreDirs)) {
|
|
243
|
+
continue
|
|
244
|
+
}
|
|
221
245
|
queue.push(filePath)
|
|
222
246
|
} else {
|
|
223
247
|
callback(filePath)
|