Skip to content

Commit

Permalink
1.2.4 optimize build.js
Browse files Browse the repository at this point in the history
  • Loading branch information
bddjr committed Jan 9, 2025
1 parent 308c2d0 commit 146a655
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 24 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ vite v6.0.6 building for production...
45 modules transformed.
rendering chunks (1)...

vite-plugin-singlefile-compression 1.2.3 building...
vite-plugin-singlefile-compression 1.2.4 building...

file:///D:/bddjr/Desktop/code/js/vite-plugin-singlefile-compression/test/dist/index.html
101.02 KiB -> 46.52 KiB

Finish.

dist/index.html 47.64 kB
built in 687ms
built in 690ms
```
## Clone
Expand Down
22 changes: 3 additions & 19 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,19 @@ let result = esbuild.buildSync({
entryPoints: [
"src/template.js",
"src/template-assets.js",
],
outdir: "dist",
minifyWhitespace: true,
write: false,
})

if (result.errors.length)
throw result.errors

for (const i of result.outputFiles) {
fs.writeFileSync(i.path, i.text.replace(/;?\n?$/, ''))
}

result = esbuild.buildSync({
entryPoints: [
"src/template-base128.js",
],
outdir: "dist",
minify: true,
bundle: true,
format: 'esm',
charset: 'ascii',
write: false,
})

if (result.errors.length)
throw result.errors

for (const i of result.outputFiles) {
fs.writeFileSync(i.path,
i.text
.replace(/^\(\(\)=>\{/, '')
.replace(/;?\}\)\(\);\n$/, ''))
fs.writeFileSync(i.path, i.text.replace(/;?\n?$/, ''))
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite-plugin-singlefile-compression",
"version": "1.2.3",
"version": "1.2.4",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"files": [
Expand Down

0 comments on commit 146a655

Please sign in to comment.