Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F1262930
build.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
build.ts
View Options
import
{
build
,
BuildResult
}
from
"esbuild"
;
import
{
sassPlugin
}
from
"esbuild-sass-plugin"
;
import
*
as
chokidar
from
"chokidar"
;
import
{
default
as
glob
}
from
"tiny-glob"
;
import
{
generateScssIncludes
}
from
"./find-scss-includes"
;
import
{
sleep
}
from
"./utils/sleep"
;
import
{
generateCollections
}
from
"./generate-collections"
;
import
{
generateRoutes
}
from
"./generate-routes"
;
async
function
build_ts
()
{
const
[
entryPoints
]
=
await
Promise
.
all
([
glob
(
"./src/back/**/*.ts"
),
generateCollections
(),
generateRoutes
(),
]);
await
build
({
entryPoints
,
sourcemap
:
true
,
outdir
:
"./dist/back"
,
logLevel
:
"info"
,
platform
:
"node"
,
target
:
"node16"
,
format
:
"cjs"
,
});
}
async
function
complex_build
(
watch
:
boolean
)
:
Promise
<
void
>
{
let
scss_build
:
BuildResult
|
null
=
null
;
if
(
watch
)
{
const
scss_watcher
=
chokidar
.
watch
(
"src"
,
{
ignoreInitial
:
true
});
scss_watcher
.
on
(
"all"
,
async
(
_
,
path
)
=>
{
if
(
!
scss_build
)
return
;
if
(
path
.
endsWith
(
".scss"
)
&&
!
path
.
endsWith
(
"/includes.scss"
))
{
// refresh the list of all scss files in includes.scss
await
generateScssIncludes
();
try
{
await
scss_build
?
.
rebuild
?
.();
console
.
log
(
`Built main.scss [on
${
path
}
]`
);
}
catch
(
e
)
{
console
.
error
(
e
.
message
);
await
sleep
(
200
);
scss_build
?
.
rebuild
?
.()
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
.
catch
((
e
)
=>
console
.
error
(
e
?
.
message
));
}
}
if
(
path
.
endsWith
(
".ts"
)
&&
!
path
.
endsWith
(
"src/back/collections.ts"
)
&&
!
path
.
endsWith
(
"src/back/routes/routes.ts"
)
)
{
await
build_ts
();
console
.
log
(
`Finished TS build [on
${
path
}
]`
);
}
});
}
try
{
scss_build
=
await
build
({
entryPoints
:
[
"./src/main.scss"
],
sourcemap
:
true
,
outfile
:
"./public/dist/style.css"
,
logLevel
:
"info"
,
incremental
:
watch
,
plugins
:
[
sassPlugin
()],
});
await
build_ts
();
watch
&&
scss_build
?
.
rebuild
?
.();
}
catch
(
e
)
{
console
.
error
(
e
);
}
}
export
async
function
buildProject
(...
args
:
string
[])
:
Promise
<
void
>
{
const
watch
=
args
.
includes
(
"--watch"
);
await
build
({
entryPoints
:
[
"./src/front/index.ts"
],
sourcemap
:
true
,
outfile
:
"./public/dist/bundle.js"
,
logLevel
:
"info"
,
bundle
:
true
,
watch
,
});
try
{
await
complex_build
(
watch
);
}
catch
(
e
)
{
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
console
.
error
(
e
.
message
);
await
buildProject
(...
args
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Fri, Jan 24, 15:16 (17 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
600071
Default Alt Text
build.ts (2 KB)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline
Log In to Comment