Deploy with Now, inline CSS - #221
Conversation
…to fewer-scrollbars
|
FYI, I originally thought that moving all of the Primer CSS styles into our Apparently—TIL!—styles in |
|
Also, I ran a Lighthouse audit in Chrome Devtools on this to compare with primer.github.io/primer-react. The live site scores 61 on performance, but this one scores 80. 💥
|
|
I was hoping this would mean we wouldn't need to check in the |
|
@jonrohan I think this gets at least one step closer to that goal. I tried getting this to just run I think Now just runs
I'm totally happy to give this a stab (maybe in a separate PR?), but I'd like to time-box it. @emplums, what do you think? |
| "add-react-displayname", | ||
| "transform-object-rest-spread" | ||
| "transform-object-rest-spread", | ||
| "preval" |
There was a problem hiding this comment.
We use this babel plugin to inline the CSS.
| ) | ||
| {examples.map(example => ( | ||
| <NavLink | ||
| className="menu-item no-underline link-gray-dark" |
There was a problem hiding this comment.
Note: only menu-item comes from primer-navigation. The other classes here come from primer-utilities.
| } | ||
|
|
||
| export default Styles | ||
| export default withDefaultTheme(Styles) |
There was a problem hiding this comment.
Note: This allows the theme to override the base styles, so long as you either wrap <Styles /> in a ThemeProvider or pass theme={theme} directly.
| "lint": "eslint src examples", | ||
| "prepublishOnly": "npm run build", | ||
| "start": "x0 dev examples -op 8888", | ||
| "start": "x0 dev examples -op ${PORT:-8888}", |
There was a problem hiding this comment.
This was an attempt to get the PORT env variable set by Now working with x0. The problem I ran into once I got that working was that x0's HTTP server doesn't seem to like upgrading from HTTP to HTTPS.
| "dist": "NODE_ENV=production rollup -c && npm run build:css", | ||
| "predist": "rm -rf dist", | ||
| "prepublishOnly": "npm run dist", | ||
| "build:css": "primer-module-build --outputDir dist/css src/primer-react.scss", |
There was a problem hiding this comment.
We can use primer-module-build without any additional configuration to compile our custom CSS bundle. This generates dist/css/build.css and dist/css/index.js.


This PR builds on #218 with a couple of changes that make it deployable to Now:
buildnpm script is now calleddist(which makes sense, since it builds thedistdirectory).now.jsonthat configures the project for static deployment out of thedocsdirectory.unpkg.comURLs! 🎉