everywall / ladder

Selfhosted alternative to 12ft.io. and 1ft.io bypass paywalls with a proxy ladder and remove CORS headers from any URL
GNU General Public License v3.0
4.29k stars 169 forks source link

Proposal: Use Tailwind CLI instead of play CDN #34

Closed joncrangle closed 7 months ago

joncrangle commented 7 months ago

The Tailwind Play CDN isn't recommended for production since it includes the whole Tailwind class library (large bundle). Proposal is to use the Tailwind CLI instead so that there is a css build step resulting in minified css of only the classes that are used (small bundle).

https://tailwindcss.com/docs/installation

deoxykev commented 7 months ago

I think it would be a good idea to make the build step in a separate directory, and compile the form into a single html file including tailwind. This way it can still be embedded into the binary. Also commit a default html into the repo, so that one could build the binary using just go, and without npm.

joncrangle commented 7 months ago

I played around with the concept a bit in a branch for demo purposes.

There is a build script that can be run with pnpm build. It uses the Tailwind CLI to build the css and then minifies it into the /assets directory. I used the Go Fiber Static method to serve the /assets directory, so this stylesheet can be used within the html as <link rel="stylesheet" href="/assets/styles.css">.

Perhaps a Github action could run the build script whenever the form.html page is changed to ensure that the stylesheet is updated with any Tailwind utlity classes that are required.

deoxykev commented 7 months ago

I think it’ll be better to serve the ‘assets/styles.css’ via a custom get handler in Go Fiber that serves a go:embed version of it. This way, the built tailwind styles are baked into the binary itself, rather than reaching into a directory (as the Static method does)

this would make deployment on edge systems simpler (IE: lambda, CF workers, etc) and be much more portable.

joncrangle commented 7 months ago

Thanks for the feedback. I've updated the branch to use go:embed and a get handler rather that the static method.

mms-gianni commented 7 months ago

I needed some tweaks to let it run, but it works now.