@chtibizoux/hono-vite-netlify
TypeScript icon, indicating that this package has built-in type declarations

0.1.7 • Public • Published

@hono/vite-netlify

@hono/vite-netlify is a Vite plugin to build your Hono application for Bun.

Usage

Installation

You can install vite and @hono/vite-netlify via npm.

npm i -D vite @hono/vite-netlify

Or you can install them with Bun.

bun add vite @hono/vite-netlify

Settings

Add "type": "module" to your package.json. Then, create vite.config.ts and edit it.

import { defineConfig } from 'vite'
import pages from '@hono/vite-netlify/functions'
// or: import pages from '@hono/vite-netlify/edge-functions'

export default defineConfig({
  plugins: [pages()],
})

Build

Just run vite build.

npm exec vite build

Or

bunx --bun vite build

Deploy to Netlify

Run the netlify command.

netlify deploy --prod

Options

The options are below.

type NetlifyOptions = {
  entry?: string | string[]
  outputDir?: string
  external?: string[]
  minify?: boolean
  emptyOutDir?: boolean
}

Default values:

export const defaultOptions = {
  entry: ['./src/index.tsx', './app/server.ts'],
  outputDir: './dist',
  external: [],
  minify: true,
  emptyOutDir: false,
}

Build a client

If you also want to build a client-side script, you can configure it as follows.

export default defineConfig(({ mode }) => {
  if (mode === 'client') {
    return {
      build: {
        rollupOptions: {
          input: './src/client.ts',
          output: {
            dir: './dist/static',
            entryFileNames: 'client.js',
          },
        },
        copyPublicDir: false,
      },
    }
  } else {
    return {
      plugins: [pages()],
    }
  }
})

The build command:

vite build --mode client && vite build

Authors

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @chtibizoux/hono-vite-netlify

Weekly Downloads

0

Version

0.1.7

License

MIT

Unpacked Size

11.8 kB

Total Files

19

Last publish

Collaborators

  • chtibizoux