|
1 | 1 | # @hono/vite-build |
2 | 2 |
|
| 3 | +## 1.3.0 |
| 4 | + |
| 5 | +### Minor Changes |
| 6 | + |
| 7 | +- [#218](https://github.com/honojs/vite-plugins/pull/218) [`65e2f768a26d0665aaa05f60abf36bb66a6b6fa9`](https://github.com/honojs/vite-plugins/commit/65e2f768a26d0665aaa05f60abf36bb66a6b6fa9) Thanks [@chadxz](https://github.com/chadxz)! - Added a new Netlify Functions build adapter. |
| 8 | + |
| 9 | + This adapter can be imported from `@hono/vite-build/netlify-functions` and will |
| 10 | + compile your Hono app to comply with the requirements of the Netlify Functions |
| 11 | + runtime. |
| 12 | + |
| 13 | + - The default export will have the `hono/netlify` adapter applied to it. |
| 14 | + - A `config` object will be exported, setting the function path to `'/*'` and |
| 15 | + `preferStatic` to `true`. |
| 16 | + |
| 17 | + Please note, this is for the Netlify Functions runtime, not the Netlify Edge |
| 18 | + Functions runtime. |
| 19 | + |
| 20 | + Example: |
| 21 | + |
| 22 | + ```ts |
| 23 | + // vite.config.ts |
| 24 | + import { defineConfig } from 'vite' |
| 25 | + import devServer from '@hono/vite-dev-server' |
| 26 | + import build from '@hono/vite-build/netlify-functions' |
| 27 | + |
| 28 | + export default defineConfig({ |
| 29 | + plugins: [ |
| 30 | + devServer({ |
| 31 | + entry: './src/index.ts', |
| 32 | + }), |
| 33 | + build({ |
| 34 | + entry: './src/index.ts', |
| 35 | + output: 'functions/server/index.js', |
| 36 | + }), |
| 37 | + ], |
| 38 | + }) |
| 39 | + ``` |
| 40 | + |
| 41 | + If you also have a `public/publish` directory for your assets that should be |
| 42 | + published to the corresponding Netlify site, then after running a build, you |
| 43 | + would end up with a directory structure like: |
| 44 | + |
| 45 | + ``` |
| 46 | + dist/ |
| 47 | + functions/ |
| 48 | + server/ |
| 49 | + index.js |
| 50 | + publish/ |
| 51 | + robots.txt |
| 52 | + .... |
| 53 | + ``` |
| 54 | + |
| 55 | + then you can use a netlify.toml that looks like: |
| 56 | + |
| 57 | + ```toml |
| 58 | + # https://ntl.fyi/file-based-build-config |
| 59 | + [build] |
| 60 | + command = "vite build" |
| 61 | + functions = "dist/functions" |
| 62 | + publish = "dist/publish" |
| 63 | + ``` |
| 64 | + |
3 | 65 | ## 1.2.1 |
4 | 66 |
|
5 | 67 | ### Patch Changes |
|
0 commit comments