-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BETA] Update tests, builds, and css minification
- Loading branch information
1 parent
0bddcfb
commit 8697174
Showing
4 changed files
with
111 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import dts from 'rollup-plugin-dts'; | ||
import { createMinifier } from 'dts-minify'; | ||
import * as ts from 'typescript'; | ||
import { writeFileSync } from 'fs'; | ||
|
||
const minifier = createMinifier(ts); | ||
|
||
const minifyPlugin = { | ||
name: 'minify-dts', | ||
writeBundle(options, bundle) { | ||
for (const fileName in bundle) { | ||
const file = bundle[fileName]; | ||
if (fileName.endsWith('.d.ts')) { | ||
const minified = minifier.minify(file.code, { | ||
keepJsDocs: false | ||
}); | ||
writeFileSync(options.file, minified); | ||
} | ||
} | ||
} | ||
}; | ||
|
||
export default { | ||
input: './src/index.ts', | ||
output: { | ||
file: 'dist/index.d.ts', | ||
format: 'es' | ||
}, | ||
plugins: [dts(), minifyPlugin] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bun | ||
export {}; | ||
|
||
const inputFile = Bun.argv[2]; | ||
if (!inputFile) { | ||
console.error('Please provide a CSS file to minify'); | ||
process.exit(1); | ||
} | ||
|
||
const css = await Bun.file(inputFile).text(); | ||
|
||
// Simple CSS minification | ||
const minified = css | ||
.replace(/\/\*(?:(?!\*\/)[\s\S])*\*\/|[\r\n\t]+/g, '') // Remove comments and whitespace | ||
.replace(/ {2,}/g, ' ') // Remove multiple spaces | ||
.replace(/ ([{:}]) /g, '$1') // Remove spaces around brackets and colons | ||
.replace(/([{:}]) /g, '$1') // Remove spaces after brackets and colons | ||
.replace(/;}/g, '}') // Remove last semicolon in block | ||
.trim(); | ||
|
||
console.log(minified); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters