Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@preact/preset-vite

Package Overview
Dependencies
Maintainers
8
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@preact/preset-vite

Preact preset for the vite bundler

  • 2.7.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
45K
decreased by-25.12%
Maintainers
8
Weekly downloads
 
Created
Source

@preact/preset-vite

An all in one preset for writing Preact apps with the vite bundler.

Features:

  • Sets up Hot Module Replacement via prefresh
  • Enables Preact Devtools bridge during development
  • Aliases React to preact/compat

Installation

First intall the preset package from npm:

npm install --save-dev @preact/preset-vite
# or
yarn add -D @preact/preset-vite

Enhance your vite config with the Preact preset plugin in your vite.config.ts or vite.config.js:

import { defineConfig } from "vite";
import preact from "@preact/preset-vite";

export default defineConfig({
  plugins: [preact()]
});

Options

Options can be passed to our preset plugin via the first argument:

export default defineConfig({
  plugins: [
    preact({ devtoolsInProd: true })
  ]
});

Available options

OptionTypeDefaultDescription
devToolsEnabledbooleantrueInject devtools bridge
prefreshEnabledbooleantrueInject Prefresh for HMR
devtoolsInProdbooleanfalseInject devtools bridge in production bundle instead of only in development mode
reactAliasesEnabledbooleantrueAliases react, react-dom to preact/compat

Babel configuration

The babel option lets you add plugins, presets, and other configuration to the Babel transformation performed on each JSX/TSX file.

preact({
  babel: {
    presets: [...],
    // Your plugins run before any built-in transform (eg: Fast Refresh)
    plugins: [...],
    // Use .babelrc files
    babelrc: true,
    // Use babel.config.js files
    configFile: true,
  }
})

License

MIT, see the license file.

Keywords

FAQs

Package last updated on 17 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc