lydell
October 29, 2022, 2:17pm
1
I just released elm-watch 1.1.0, with a bunch of edge case fixes and a couple of new features!
The biggest feature is the opt-in error overlay in the browser, with clickable error locations!
You can now move the browser UI to a different corner.
I go through those two features in more detail in this video:
Full changelog:
Note: If you use elm-watch together with run-pty , make sure to update run-pty to 4.0.2 or later!
42 Likes
These are all really cool and useful features! Amazing job!
Loved the intro to the video as well
3 Likes
dirkbj
November 1, 2022, 4:47pm
3
Well done! These are great additions. Excited to see the next update.
1 Like
Great video about a great tool. There is only one thing holding me back from moving from elm-live to elm-watch and that is the proxy functionality to reach the back-end. I know you do not want to extend elm-watch with all kind of none-core functionalities. But do you know a good tool to setup a proxy to the back-end that could work alongside elm-watch?
lydell
November 2, 2022, 5:35am
5
Personally, I don’t use a tool for proxying – I write a little bit of Node.js code to have full control. You can see that in the example dev server .
Specifically, here is a function for proxying a backend (you could simplify it to always go to 127.0.0.1 but to a certain port):
function proxyToWeb(req, res, log, hostname) {
const options = {
hostname,
path: req.url,
method: req.method,
headers: { ...req.headers, host: hostname },
};
const proxyReq = https.request(options, (proxyRes) => {
const { statusCode } = proxyRes;
log(`-> ${hostname}`, statusCode);
res.writeHead(statusCode, proxyRes.headers);
proxyRes.pipe(res, { end: true });
});
proxyReq.on("error", (error) => {
log(503);
res.writeHead(503);
res.end(`Failed to proxy to ${hostname}. Is it down?\n\n${error.stack}`);
});
This file has been truncated. show original
I recently copied that example and reduced it to just one app when I needed it for a project:
function formatTime(date) {
return [date.getHours(), date.getMinutes(), date.getSeconds()]
.map((number) => number.toString().padStart(2, "0"))
.join(":");
}
const server = http.createServer((req, res) => {
const log = makeLog(req);
if (req.url.startsWith("/api/")) {
proxyToWeb(req, res, log, "ci.concourse-ci.org");
} else {
serveFile(
req,
res,
log,
looksLikeFile(req.url) ? req.url : "/public/index.html"
);
}
});
2 Likes
Thanks for your extensive reply. I highly appreciate it. I will move to elm-watch
rupert
November 3, 2022, 9:52am
7
Just wanted to say elm-watch is really exellent, thanks for making it.
We already have a build that runs in a loop using webpack to make the dev/prod builds. However, even with that running I will typically run elm-watch alongside, like this npx elm-watch hot. As I code the Elm side, I tend to look at the output of that over our proper build, since it is very fast and easier to read.
3 Likes
system
Closed
November 13, 2022, 9:53am
8
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.