npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vite-plugin-custom-domain

v1.0.1

Published

Allows you to use a custom domain name when developing locally. It does this by modifying your /etc/hosts file

Downloads

11

Readme

vite-plugin-custom-domain

Demo example

Have you ever wanted to use a custom domain name either than localhost when developing locally?
This plugin allows you to do just that and you don't need to set up anything in order to make it work.

Just specify the domain name and you are good to go.

Installation

You can install using any of your package manangers

  • pnpm
    pnpm add -D vite-plugin-custom-domain

  • npm
    npm install --save-dev vite-plugin-custom-domain

  • yarn
    yarn add -D vite-plugin-custom-domain

Usage

Using it is very simple, just see.
Inside your vite.config.ts or vite.config.js file, import the module.

// vite.config.js
import { defineConfig } from "vite";
import customDomain from "vite-plugin-custom-domain";

export default defaultConfig({
    plugins: [
        customDomain({
            // You can specify any number of domain names
            "127.0.0.1":  ["website.demo.test","admin.demo.test"],
        })
    ],
    //Then you specify the domain name which should be used primarily
    host: "website.demo.test"
})

If you are using localhost, you need to use 127.0.0.1 then you add any number of domain names you want. You can also specify more ip addresses if you want.

// vite.config.js
import { defineConfig } from "vite";

export default defaultConfig({
    plugins: [
        customDomain({
            // You can specify any number of domain names
            "127.0.0.1":  ["website.demo.test","admin.demo.test"],
            "198.183.23.1": ["facebook.test","google.test","whatsapp.test"]
        })
    ],
    //Then you specify the domain name which should be used primarily
    host: "website.demo.test"
})

and that's all, your vite server will open on the name which you provided in the host option.

How does it work?

It works by adding the domain name which you specify to your /etc/hosts file.

I know you can manually add the domain name which you want to use to your /etc/hosts file but the advantage of this plugin is that, it doesn't clutter the file. The domain names are only added when you call vite and they are removed immediately you close the dev server.

It tries to remove the domain name even if you forcefully close the server. Give it a star on github if you found it useful