New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@gtramontina.com/bun-html-live-reload

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gtramontina.com/bun-html-live-reload

HTML live reload for Bun

  • 1.0.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
141
decreased by-36.2%
Maintainers
1
Weekly downloads
 
Created
Source

Bun Logo Bun HTML Live Reload

Getting Started

Install

bun add -d @gtramontina.com/bun-html-live-reload

Usage

Using the following as a regular Bun server as a starting point:

// index.ts

Bun.serve({
    fetch: () => {
        return new Response("<div>hello world!</div>", {
            headers: { "Content-Type": "text/html" },
        });
    },
    port: 8888,
});

Import htmlLiveReload and wrap your server with it:

// index.ts

import { htmlLiveReload } from "@gtramontina.com/bun-html-live-reload";

Bun.serve(
    htmlLiveReload({
        fetch: () => {
            return new Response("<div>hello world!</div>", {
                headers: { "Content-Type": "text/html" },
            });
        },
        port: 8888,
    }),
);

Running the server with bun --hot index.ts will now force a reload of the current page whenever Bun --hot detects a change. It will also force a reload of the stylesheets when a change to a text/css file is detected. For an example, take a look at the example directory and run bun run:example.

Options

watchPath

Bun HTML Live Reload will always force a reload when running it --hot. In order to have a more fine-grained control over the files not detected by Bun's --hot mode, the watchPath option can be passed to htmlLiveReload as such:

// index.ts

import { htmlLiveReload } from "@gtramontina.com/bun-html-live-reload";

Bun.serve(
    htmlLiveReload(
        { /* server options */ },
        {
            watchPath: path.resolve(import.meta.dir, "src"),
        }
    ),
);

buildConfig

If your setup makes use of Bun.build(), you can forward the settings to htmlLiveReload via the buildConfig option:

// index.ts

import { htmlLiveReload } from "@gtramontina.com/bun-html-live-reload";

Bun.serve(
    htmlLiveReload(
        { /* server options */ },
        {
            buildConfig: {
                entrypoints: ['./index.tsx'],
                outdir: './build',
            },
        }
    ),
);

FAQs

Package last updated on 16 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc