`npm install -save next next-plugin-preact preact preact-render-to-string` The first step is to install all dependencies and set the correct aliasing: next-plugin-react is available on npm, and it takes only two steps to install. I did this process for v web application, and it was so much easier than I imagined. The Preact team maintains a plugin to make the migration for a Next.js application a breeze as well. The same holds for the other packages mentioned in the configuration as well. This configuration tells webpack that wherever it sees import something from 'react' it will substitute it with import something from preact/compat. You can check out the official docs for more bundlers. You need to add the above snippet in your webpack config file. "react-dom/test-utils": "preact/test-utils", Let's see what it takes to do aliasing with webpack. That's it! We don't need to change our imports or our code in any way. In our case, we specify our bundler that react and react-dom are resolved by using preact/compat. In "aliasing", we tell our bundler that a specific import is resolved using a different import. The only single-step required is "aliasing". The key lies in the preact/compat, the compatibility layer. The Preact team did magnificent work in helping developers migrating from React to Preact. This is an important decision factor, especially in enterprises.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |