Smallweb 0.11 - Global config and new routing
by Achille Lacoin
2 min read
A new (optional) global config
You can now configure the smallweb host, port, and other global settings in a ~/.config/smallweb/config.json
file.
Here is the implicit default configuration if the file does not exist:
{
"host": "127.0.0.1",
"port": 7777,
"domains": {
"*.localhost": "~/localhost/*"
},
"env": {
"DENO_TLS_CA_STORE": "system"
}
}
Smallweb also supports the following environment variables:
SMALLWEB_HOST
SMALLWEB_PORT
Config Based Routing
You might have noticed the new domains
key in the global config.
It's part of a new routing system that allows you to map domains to folders in your filesystem.
For example, you can map:
pomdtr.me
to~/pomdtr.me
: All requests topomdtr.me
will be served from the~/pomdtr.me
folder.*.smallweb.run
to~/smallweb.run/*
: All requests to<app>.smallweb.run
will be served from the~/smallweb.run/<app>
folder.*.example.me
to~/example.com
: All requests to*.example.me
will be served from the~/example.com
folder.
The config is live-reloaded, so you can change it on the fly.
I hope this new system will allows advanced users to handle more advanced routing scenarios, while keeping the simplicity of the original system.
This change also means that the notion of a "smallweb root" is now deprecated. You can put your smallweb apps anywhere in your filesystem.
smallweb open
Smallweb open now works on top of directories.
To open the app from the current directory in your browser, you can run:
smallweb open .
Or do something like this if you have a blog stored at ~/localhost/blog
:
smallweb open ~/localhost/blog
smallweb create
-> smallweb init
smallweb create
was replaced by smallweb init
.
If you want smallweb init
, you'll get an interactive prompt to create a new project.
You can also skip the prompts by passing the appropriate args and flags.
smallweb init ~/localhost/hono-app --template hono