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

[FR] Read styles from local filesystem #1252

Closed
NightMachinery opened this issue May 18, 2021 · 6 comments
Closed

[FR] Read styles from local filesystem #1252

NightMachinery opened this issue May 18, 2021 · 6 comments

Comments

@NightMachinery
Copy link

NightMachinery commented May 18, 2021

It would be very good if Stylus could read styles from a dir on the local filesystem, and apply the styles with hot reload. The options of a style can be put in the comments at the start of the CSS files.

For example, suppose Stylus is set to read the dir ~/userstyles/. I put this style there as ~/userstyles/x.css:

/* StylusConfigBeginToml
domain = "www.google.com" 
StylusConfigEnd */

#searchform * > div {
   width: auto;
   margin-left: auto;
}

Then Stylus automatically applies this style on www.google.com domains, with hot reload when the file changes.

This workflow has two major benefits:

  • Sync with whatever the user likes (git, Dropbox, webDAV, etc)
  • Edit the CSS with any text editor the user likes (emacs, vim, VSCode, etc)

Related:

@tophf
Copy link
Member

tophf commented May 18, 2021

One way to implement it is file:// access from the background script, but it won't work in Firefox. In Chrome we can do it, but there's no "onchange" event so all these file URLs would have to be re-checked every second which means 36,000 checks in ten hours per one file and that's just wasteful. In Chrome we could have used Native FileSystem API but yet again it won't work in Firefox. A universal solution could be nativeMessaging API that runs a separate external app, but none of us has been interested since Schomery tried to implement it four years ago. The idea per se is fine so the issue can stay open in case someone decides to take a stab at it.

P.S. The internal format of the files should be UserCSS, no need to reinvent the wheel.

@NightMachinery
Copy link
Author

@tophf Polling is fine if we make it sth the user activates when they want to develop. We can optionally turn it off after three hours and show a notification.

@tophf
Copy link
Member

tophf commented May 18, 2021

On-demand polling is already implemented, see Writing UserCSS.

@disco0
Copy link

disco0 commented May 19, 2021

On the topic of IDEs—thoughts on adding(/accepting a PR for) GhostText integration? There's some early discussion of an extension API using onConnectExternal/onMessageExternal. At least for userstyles, I'd gladly take Dropbox sync with live editing in VSCode over file:/// any day

@tophf tophf closed this as not planned Won't fix, can't repro, duplicate, stale Dec 2, 2023
@vitaly-zdanevich
Copy link

Not planned? The integrated editor is slow on my side :(

@tophf
Copy link
Member

tophf commented Feb 16, 2024

It's already implemented as "live reload", see Writing UserCSS.

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

No branches or pull requests

4 participants