Giter VIP home page Giter VIP logo

Comments (3)

harrysolovay avatar harrysolovay commented on July 28, 2024 1

If you look at the customize-cra-react-refresh package, you'll see it makes two changes to your config:

  1. the react-refresh/babel Babel plugin is added
  2. the @pmmmwh/react-refresh-webpack-plugin plugin is added

After installing these two dependencies, you should be able to do the following:

const {appendWebpackPlugin} = require(@rescripts/utils);
const ReactRefreshPlugin = require("@pmmmwh/react-refresh-webpack-plugin");

const isDevelopment = process.env.NODE_ENV !== "production";

module.exports = [
  ['use-babel-config', '.babelrc'],
  isDevelopment
    ? [appendWebpackPlugin(new ReactRefreshPlugin(...yourOptions))]
    : config => config
]

Finally, specify the react-refresh babel plugin in your .babelrc.

[
  "plugins": [
    "react-app",
    "react-refresh/babel"
  ]
]

Please try this out and let me know if you need more help

from rescripts.

jizusun avatar jizusun commented on July 28, 2024

@harrysolovay It works pretty well on a CRA app!
https://github.com/jizusun/react-typescript-fast-refresh/pull/2/files

Thank you for this great project!

By the way, only a small typo in your answer 😄

- const {appendWebpackPlugin} = require(@rescripts/utils);
+ const {appendWebpackPlugin} = require('@rescripts/utilities')

from rescripts.

jizusun avatar jizusun commented on July 28, 2024

Hi @harrysolovay Excuse me, but I just found it very strange

Maybe I should dive deep into the code, but do you have any guess about why doesn't it work?
My guess is customize-cra-react-refresh use a pretty old react-refresh-webpack-plugin
And how can I try rescripts + customize-cra-react-refresh?

Thanks so much for your help ❤️

from rescripts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.