Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In dev mode, bypass 11ty and watch the css file ourself and reference… #108

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

theor
Copy link

@theor theor commented Sep 30, 2021

… the stylesheet. This skips the lengthy 11ty rebuild and allows browsersync to reload only the css. Still inline it in build mode.

ATM I use isDevelopment (argv.contains("--serve") to toggle the feature, not sure if that's the right way to do it.

remaining issue: a test expects a style tag, when in dev mode it should now expect a link tag.

Before:

MmKCyIGT3m

After:

ezgif-4-5b60036bc4e3

@google-cla
Copy link

google-cla bot commented Sep 30, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@theor theor mentioned this pull request Sep 30, 2021
@theor
Copy link
Author

theor commented Sep 30, 2021

@googlebot I signed it!

content = content.replace("</head>", `<style>${after}</style></head>`);
// in watch/serve mode, reference the stylesheet. As we bypass 11ty rebuild,
// Browsersync will reload only the css file, which is really fast
if (isDev) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused by this. Don't you want to do this at the start of this function and then short-circuit the minification?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still wrote the minified css back, but that could be short-circuited too yes .I'll do that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants