0.0.3 • Published 9 months ago
@gleam-tools/vite v0.0.3
@gleam-tools/vite 
Import from Gleam (*.gleam
) files directly.
Usage
npm i @gleam-tools/vite
- Create a basic Vite project (
npm create vite
) - Create a
gleam.toml
and add Gleam dependencies - Update your vite config
// vite.config.{ts,js}
import { gleam } from '@gleam-tools/vite'
export default {
plugins: [gleam()],
}
- Start importing from Gleam!
API
Note
By default, TypeScript (LSP) will complain about importing files with the .gleam
extension. There are two choices for fixes:
- If the type of the import doesn't matter , add
declare module "*.gleam";
inside any TypeScript file. A caveat is the LSP does not know if an export exists so it will not provide autocompletion when importing a Gleam file and it will type exports asany
. - Alternatively, if the vite dev server is running you can have full type safety when importing from Gleam.
npm i @gleam-tools/ts
. Create atsconfig.json
/jsconfig.json
and setcompilerOptions.plugins
to[{"name": "@gleam-tools/ts"}]
(RECOMMENDED)
0.0.3
9 months ago