1.0.4 • Published 2 years ago

vite-plugin-change-host v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

vite-plugin-change-host

A vite plugin to change the host of the dev server.
Actual work is append host list in to os hosts file.
In Windows C:\Windows\System32\drivers\etc\hosts and macOS /etc/hosts.
And it changes the server, preview host property in vite config.

{
    server: {
        //...
        host: 'home.exmaple.com'
    },
    preview: {
        //...
        host: 'home.exmaple.com'
    }
}

Install

npm install vite-plugin-change-host
yarn add vite-plugin-change-host

Usage

vite.config.js

export default defineConfig({
    plugins: [
        changeHost({
            host: 'home.exmaple.com', // set dev server host
            additionalHosts: ['example.com', 'api.example.com'], // additional hosts
            customPath:'C:\\Windows\\System32\\drivers\\etc\\hosts' // if you use wsl in Windows, might be needed.
        }),
    ],
})

// ...

// you'd better clean up the hosts when devserver is closed
process.on('SIGINT', () => {
    cleanUpHosts();
    process.exit();
});

Note

  • Host changes when command vite , vite preview is executed.(not build)
1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago