@z-code/vite-plugin-swc
v0.5.0
Published
Vite plugin for transforming source files with SWC.
Downloads
14
Maintainers
Readme
@z-code/vite-plugin-swc
Transform your TypeScript / JavaScript source files with SWC within your Vite build process.
Thanks
This Project is a fork of vite-plugin-swc-transform and thanks a lot for your grate work Timothée “Tim” Pillard
Install
yarn add @z-code/vite-plugin-swc --dev
or
npm i @z-code/vite-plugin-swc --save-dev
Usage
vite.config.ts:
import { defineConfig } from "vite"
import swc from "@z-code/vite-plugin-swc"
export default defineConfig({
plugins: [swc()],
})
The plugin will default to the following options:
Note: This options support Top Level Await, Stage 3 Decorators in Vanilla TypeScript
{
include: /\.ts?$/,
exclude: "node_modules",
swcrc: false,
configFile: false,
minify: true,
jsc: {
parser: {
syntax: "typescript",
decorators: true,
},
transform: {
decoratorMetadata: true,
decoratorVersion: "2022-03",
},
},
}
If you want to use .swcrc file:
import { defineConfig } from "vite"
import swc from "@z-code/vite-plugin-swc"
export default defineConfig({
plugins: [
swc({
include: /\.ts?$/,
swcrc: true,
configFile: true,
}),
],
})
Example .swcrc:
{
"$schema": "https://json.schemastore.org/swcrc",
"exclude": "node_modules",
"minify": true,
"jsc": {
"parser": {
"syntax": "typescript",
"decorators": true
},
"transform": {
"decoratorMetadata": true,
"decoratorVersion": "2022-03"
}
}
}