NYCPlanning / nyc-planning-style-guide

Base styles for NYC Department of City Planning (using Foundation for Sites)
https://nyc-planning-style-guide.netlify.com/
1 stars 1 forks source link

Serve compiled .css and .js via CDN #21

Closed andycochran closed 4 years ago

andycochran commented 4 years ago

@bfreeds pointed out how it'd be great to serve the .css and .js files via CDN instead of requiring download. This would make prototyping really quick/easy—we could even prototype in e.g. CodePen.

I found https://unpkg.com/, which is "a fast, global content delivery network for everything on npm." To use this we'd just need to set up Gulp to compile/minify the two assets to a directory that gets committed.

yarn build already builds everything to dist/. But we're ignoring dist/ and don't want to commit all these generated files which are mostly for documentation. We could pipe minified css/js files to the root directory when running yarn build. Then those could be committed and the minified assets could be served at:

bfreeds commented 4 years ago

@andycochran - unpkg looks like the perfect way to get the css and js onto a CDN. One thing that makes it so nice for this purpose is that it's linked to NPM, so versioned released on NPM map nicely to the unpkg versions.

There should be a way to get this to unpkg while keeping the code repo tidy (not having to check in the dist directory or having the built files lingering in the root of the repo).

From unpkg's website: image

How are you currently publishing the styleguide to npm?