Lädt...


🔧 How to Create a React Application Post-CRA Deprecation


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

I was recently working on a project and learned that the React team deprecated create-react-app two years back. Initially, I didn't buy it But when I went to the new React-dev website, I noticed forgot about CRA they haven't mentioned how to create a simple React+bundler App

Create a React App Without CRA: Using Vite or Webpack
Since the React team deprecated create-react-app (CRA), developers are looking for alternative ways to set up their React applications. Two popular choices are Vite and Webpack. In this post, we will compare these tools and provide basic setup instructions for each.

Vite vs. Webpack
Vite
Pros:
Fast development server with instant hot module replacement (HMR).
Built-in support for modern JavaScript features.
Minimal configuration needed to get started.
Cons:
Newer tool, so it may have less community support compared to Webpack.
Webpack
Pros:
Highly configurable and flexible for complex build setups.
Extensive plugin ecosystem and community support.
Proven track record with many large-scale applications.
Cons:
Initial configuration can be more complex and time-consuming.
Slower build times compared to Vite.
Setting Up a React App with Vite
Create a New Vite Project:

npm create vite@latest my-react-app -- --template react
cd my-react-app
npm install
Start the Development Server:

bash
Copy code
npm run dev
Vite Configuration:

Vite requires minimal configuration out of the box. The default setup should work for most React projects.
You can customize the vite.config.js if needed.
Setting Up a React App with Webpack
Initialize Your Project:

bash
Copy code
mkdir my-react-app
cd my-react-app
npm init -y
npm install react react-dom
npm install webpack webpack-cli webpack-dev-server html-webpack-plugin babel-loader @babel/core @babel/preset-env @babel/preset-react
Create Project Structure:

Create a src folder and add index.js and App.js files.
Create a public folder and add an index.html file.
Configure Webpack:

Create a webpack.config.js file:
javascript
Copy code
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(dirname, 'dist'),
filename: 'bundle.js',
},
module: {
rules: [
{
test: /.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
},
},
{
test: /.css$/,
use: ['style-loader', 'css-loader'],
},
],
},
resolve: {
extensions: ['.js', '.jsx'],
},
plugins: [
new HtmlWebpackPlugin({
template: './public/index.html',
}),
],
devServer: {
contentBase: path.join(
dirname, 'dist'),
compress: true,
port: 9000,
},
};
Babel Configuration:

Create a .babelrc file:
json
Copy code
{
"presets": ["@babel/preset-env", "@babel/preset-react"]
}
Start the Development Server:

bash
Copy code
npx webpack serve
Conclusion
Both Vite and Webpack offer powerful ways to set up a React application without CRA. Vite provides a faster and simpler setup, ideal for smaller projects and rapid development. Webpack, on the other hand, offers extensive configurability and a robust ecosystem, making it suitable for more complex projects.

Choose the tool that best fits your project requirements and preferences. Happy coding!

...

🔧 Create an SSR Application with Vite, React, React Query and React Router


📈 27.99 Punkte
🔧 Programmierung

🔧 Updating Azure DevOps Pipelines for Terraform Post SSH-RSA Deprecation


📈 24.56 Punkte
🔧 Programmierung

🔧 Create a project in React without create-react-app/vite 2023 (Spanish)


📈 23.23 Punkte
🔧 Programmierung

🔧 This Week In React #185: React Conf, React Query, refs, Next.js after, mini-react...


📈 22.37 Punkte
🔧 Programmierung

🔧 This Week In React #185: React Conf, React Query, refs, Next.js after, mini-react...


📈 22.37 Punkte
🔧 Programmierung

📰 E-POST Portal, E-POST Cloud und E-POST App werden eingestellt


📈 19.05 Punkte
📰 IT Nachrichten

📰 Deutsche Post DHL Group: App „Post & DHL“ fasst die wichtigsten Post- und Paket-Services zusammen


📈 19.05 Punkte
📰 IT Nachrichten

📰 Post-Truth, Post-West, Post-Order: Der Hack der Weltordnung


📈 19.05 Punkte
📰 IT Nachrichten

📰 Voice of the Customer deprecation


📈 18.2 Punkte
📰 IT Nachrichten

🪟 Say goodbye to Windows 11 Tips app. Microsoft announces its deprecation today


📈 18.2 Punkte
🪟 Windows Tipps

📰 Quick Heal announces SHA-1 deprecation for its products


📈 18.2 Punkte
📰 IT Security Nachrichten

📰 Microsoft Starts the SHA-1 Deprecation Countdown for Edge and IE11 Browsers


📈 18.2 Punkte
📰 IT Security

📰 Technical Update: Deprecation of MySQL 5.1/5.5, MariaDB 5.5/10.0/10.1, and Percona 5.5/5.6 PHP bindings


📈 18.2 Punkte
🐧 Unix Server

📰 Deprecation of Unified Service Desk 3.2 and lower versions, and features


📈 18.2 Punkte
📰 IT Nachrichten

🔧 Sanitizer API deprecation


📈 18.2 Punkte
🔧 Programmierung

📰 What Docker runtime deprecation means for your Kubernetes


📈 18.2 Punkte
📰 IT Security Nachrichten

📰 New SWEET32 Crypto Attacks Speed Up Deprecation of 3DES, Blowfish


📈 18.2 Punkte
📰 IT Security

📰 VBScript's 'Deprecation' Confirmed by Microsoft - and Eventual Removal from Windows


📈 18.2 Punkte
📰 IT Security Nachrichten

📰 Autodesk Drops Support For Alias, VRED In macOS Mojave Over OpenGL Deprecation


📈 18.2 Punkte
📰 IT Security Nachrichten

📰 GPT-4 API general availability and deprecation of older models in the Completions API


📈 18.2 Punkte
🔧 AI Nachrichten

🎥 Now in Android: 38 - Android 12 Dev Preview 3, Google I/O 2021, RenderScript deprecation, and more!


📈 18.2 Punkte
🎥 Video | Youtube

📰 NIST Recommends SMS Two-Factor Authentication Deprecation


📈 18.2 Punkte
📰 IT Security Nachrichten

🎥 What are Chrome's Deprecation Trials?


📈 18.2 Punkte
🎥 Video | Youtube

📰 Apple Starts Preparing Mac Users for Deprecation of macOS 32-Bit Support


📈 18.2 Punkte
📰 IT Security Nachrichten

🎥 WorkManager: Deprecation of GCM NM & FCM JD - MAD Skills


📈 18.2 Punkte
🎥 Video | Youtube

🎥 What you need to know about third-party cookie deprecation


📈 18.2 Punkte
🎥 Video | Youtube

📰 Git sprints carefully towards SHA-1 deprecation


📈 18.2 Punkte
📰 IT Security Nachrichten

🪟 Microsoft Explains Deprecation


📈 18.2 Punkte
🪟 Windows Tipps

📰 Chrome 87 Released With Fix for NAT Slipstream Attacks, Broader FTP Deprecation


📈 18.2 Punkte
📰 IT Security Nachrichten

matomo