@snowpack/plugin-react-refresh

2.5.0 • Public • Published

@snowpack/plugin-react-refresh

Transforms JavaScript files containing React components automatically to enable React Fast Refresh via Snowpack's HMR API.

npm install --save-dev @snowpack/plugin-react-refresh

Setup

// snowpack.config.json
{
  "plugins": ["@snowpack/plugin-react-refresh", {/* options: see below */}]
}

Plugin Options

Name Type Description
babel boolean or object By default, this plugin uses Babel to add Fast-Refresh code to eligible JS files. If you want to configure & run this yourself, set "babel": false". Alternatively, you can pass a custom Babel configuration object to enhance or override the defaults. Most users won't need this.

How it Works

This plugin will automatically inject HMR event handlers into any file containing a React component.

In most applications, you'll still want some top-level import.meta.hot handling code in your application for any non-React file updates. In our Create Snowpack App templates, this would be the HMR handling snippet found in src/index.js.

Readme

Keywords

none

Package Sidebar

Install

npm i @snowpack/plugin-react-refresh

Weekly Downloads

4,656

Version

2.5.0

License

MIT

Unpacked Size

79.8 kB

Total Files

8

Last publish

Collaborators

  • fredkschott
  • drewpowers