fastRefreshPlugin.js 549 Bytes
Newer Older
邓晓峰's avatar
邓晓峰 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
const FastRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin/lib');
const { MFSU_NAME } = require('../constants');
const { Env } = require('../types');
module.exports = async function addFastRefreshPlugin(opts) {
  const { config, userConfig, name } = opts;
  const isDev = opts.env === Env.development;
  const useFastRefresh = isDev && userConfig.fastRefresh !== false && name !== MFSU_NAME;
  if (useFastRefresh) {
    config
      .plugin('fastRefresh')
      .after('hmr')
      .use(FastRefreshPlugin, [{ overlay: false }]);
  }
};