0.21.0 • Published 3 years ago

@reboost/plugin-react-refresh v0.21.0

Weekly downloads
75
License
MIT
Repository
github
Last release
3 years ago

npm license

React Refresh Plugin

Enables support for React Fast Refresh, so that you can develop your app faster.

Usage

Setup

Install it using npm

npm i -D @reboost/plugin-react-refresh

Import it from the package

const { start } = require('reboost');
const ReactRefreshPlugin = require('@reboost/plugin-react-refresh');

Add it to the plugins array

const { start } = require('reboost');
const ReactRefreshPlugin = require('@reboost/plugin-react-refresh');

start({
  plugins: [
    ReactRefreshPlugin({
      // Options
    })
  ]
})

Options

excludeNodeModules

Type: boolean\ Default: true

Excludes all files which match /node_modules/. Disabling it will decrease performance.

Minimal setup needed

If you want this plugin to work, please part up your components and renderers to different files.

This won't work

index.jsx

import * as React from 'react';
import * as ReactDOM from 'react-dom';

const App = () => {
  return (
    <div>Hi there!</div>
  )
}

ReactDOM.render(<App />, document.querySelector('#app'));

This works

index.jsx

import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { App } from './App';

ReactDOM.render(<App />, document.querySelector('#app'));

App.jsx

import * as React from 'react';

export const App = () => {
  return (
    <div>Hi there!</div>
  )
}

Example

Improving performance by excluding unrelated files

By default, it runs the transformation on all files. You can run the transformation only on the files which need it by using UsePlugin.

const {
  start,
  builtInPlugins: {
    UsePlugin
  }
} = require('reboost');
const ReactRefreshPlugin = require('@reboost/plugin-react-refresh');

start({
  // Other options
  plugins: [
    // Other plugins
    UsePlugin({
      include: /\.[jt]sx?$/, // Selects only the files with .js, .ts, .jsx or .tsx extension
      use: ReactRefreshPlugin()
    })
  ]
  // ...
})

License

Licensed under the MIT License.

0.21.0

3 years ago

0.20.1

3 years ago

0.20.0

3 years ago

0.19.2

3 years ago

0.19.1

3 years ago

0.19.0

3 years ago

0.18.2

3 years ago

0.18.1

3 years ago

0.18.0

3 years ago

0.17.2

4 years ago

0.17.1

4 years ago

0.17.0

4 years ago

0.16.2

4 years ago

0.16.1

4 years ago

0.16.0

4 years ago

0.15.0

4 years ago

0.14.1

4 years ago

0.14.0

4 years ago

0.13.1

4 years ago

0.13.0

4 years ago

0.12.1

4 years ago

0.12.0

4 years ago

0.11.0

4 years ago

0.10.1

4 years ago

0.10.0

4 years ago

0.9.1

4 years ago

0.8.0

4 years ago

0.7.0

4 years ago

0.6.0

4 years ago