@webpackon/use-react-refresh
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Webpackon

@webpackon/use-react-refresh

Adds react-refresh for development.

Supported loaders:

Install

npm i @webpackon/use-react-refresh --save
yarn add @webpackon/use-react-refresh

API

const { useReactRefresh } = require('@webpackon/use-react-refresh');

useReactRefresh(params: UseReactRefreshParams)(config: WebpackConfig)

UseReactRefreshParams

type UseReactRefreshParams = {
  mode: 'development' | 'production';
  transformRuntime?: 'automatic' | 'classic';
};
  • mode - webpack mode
  • swcTransformRuntime - swc option (default - automatic)

Example with babel + ts

Full examples are here

const path = require('path');

const { compose } = require('@webpackon/core');
const { useTs } = require('@webpackon/use-ts');
const { useReactRefresh } = require('@webpackon/use-react-refresh');
const { useBabel } = require('@webpackon/use-babel');

module.exports = (_, { mode }) =>
  compose(
    useReactRefresh({ mode }),
    useBabel({ useTs: true }),
    useTs(),
  )({
    target: 'web',
    entry: path.resolve(__dirname, 'src', 'index.tsx'),
  });

Example with swc and ts

const path = require('path');

const { compose } = require('@webpackon/core');
const { useTs } = require('@webpackon/use-ts');
const { useReactRefresh } = require('@webpackon/use-react-refresh');

module.exports = (_, { mode }) =>
  compose(
    useReactRefresh({ mode }),
    useTs(),
  )({
    target: 'web',
    entry: path.resolve(__dirname, 'src', 'index.tsx'),
    module: {
			rules: [
        {
          test: /\.ts$/,
          exclude: /node_modules/,
          use: {
            loader: 'swc-loader',
            options: {
              jsc: {
                parser: {
                  syntax: 'typescript'
                }
              }
            }
          }
        }
      ]
    }
  });

Package Sidebar

Install

npm i @webpackon/use-react-refresh

Weekly Downloads

6

Version

1.0.1

License

MIT

Unpacked Size

14.7 kB

Total Files

13

Last publish

Collaborators

  • and_tem