@@ -9,24 +9,6 @@ import { minifyCSS } from "./minifyCSS.js";
99const bookmarkletPlugin = options => ( {
1010 name : 'bookmarkletPlugin' ,
1111 setup ( build ) {
12- build . onLoad ( { filter : / \. ( t s x | j s ) $ / } , async args => {
13- let code = await fs . promises . readFile ( args . path , 'utf8' ) ;
14-
15- const cssRegex = / c s s ` ( [ ^ ` ] + ) ` / g;
16- let match ;
17- let newCode = code ;
18-
19- while ( ( match = cssRegex . exec ( code ) ) !== null ) {
20- const originalCSS = match [ 1 ] ;
21- const minifiedCSS = minifyCSS ( originalCSS ) ;
22- newCode = newCode . replace ( originalCSS , minifiedCSS ) ;
23- }
24-
25- return {
26- loader : 'tsx' ,
27- contents : newCode ,
28- } ;
29- } ) ;
3012 build . onEnd ( async ( result ) => {
3113 const { outputFiles } = result ;
3214 if ( ! outputFiles ) return ;
@@ -53,7 +35,7 @@ await esbuild.build({
5335 entryPoints : [ 'src/bookmarklet.js' ] ,
5436 bundle : true ,
5537 minify : true ,
56- outfile : 'dist/bookmarkletConverted.js ' ,
38+ outfile : 'dist/bookmarklet.txt ' ,
5739 write : false ,
5840 plugins : [
5941 bookmarkletPlugin ( )
@@ -71,7 +53,6 @@ await esbuild.build({
7153 <head>
7254 <meta charset="UTF-8">
7355 <meta name="viewport" content="width=device-width, initial-scale=1.0">
74- <link rel="stylesheet" href="style.css"/>
7556 <title>CAAT Color Contrast Checker Bookmarklet</title>
7657 </head>
7758 <body>
@@ -89,65 +70,5 @@ await esbuild.build({
8970 </html>
9071 ` ;
9172
92- const cssStyle = `
93- html, body {
94- margin: 0;
95- padding: 0;
96- background-color: #fff;
97- }
98- .row {
99- margin: 0 auto;
100- max-width: 45rem;
101- padding: 0 1rem;
102- }
103- h1, h2, h3, h4, h5, h6 {
104- font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;
105- font-weight: 700;
106- color: #111;
107- }
108- h1 {
109- line-height: 1.2;
110- font-size: 2rem;
111- margin-bottom: 0;
112- }
113- @media screen and (min-width: 45em) {
114- h1 {
115- font-size: 3rem;
116- }
117- }
118- h2 {
119- line-height: 1.2;
120- font-size: 1.5rem;
121- }
122- p, li {
123- font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;
124- color: #333;
125- line-height: 1.6;
126- font-size: 1.4rem;
127- }
128- p {
129- margin: 0 0 1rem 0;
130- }
131- li {
132- margin: 0 0 1rem 0;
133- }
134- ul, ol {
135- margin: 0 0 1rem 2rem;
136- padding: 0;
137- list-style-position: outside;
138- }
139- a {
140- color: #D7090E;
141- }
142- a:hover, a:focus {
143- color: #fff;
144- background-color: #ce171e;
145- border-top: 3px solid #ce171e;
146- text-decoration: none;
147- outline: none;
148- }
149- ` ;
150-
15173 fs . writeFileSync ( `${ distDir } /ccc-bookmarklet.html` , htmlContent ) ;
152- fs . writeFileSync ( `${ distDir } /style.css` , cssStyle ) ;
15374} ) ;
0 commit comments