Skip to content

Out of date with blog post #31

@jtmuller5

Description

@jtmuller5

I discovered this repo from a FreeCodeCamp blog post (https://www.freecodecamp.org/news/an-intro-to-webpack-what-it-is-and-how-to-use-it-8304ecdc3c60/) but it is fairly out of date with what was talked about in that post.

Project layout

The blog refers to a components folder but this repo does not have one. I put the App.js file directly in the src folder and updated the import statement in index.js:

import App from './App';

Index.html

The index.html should look like this. The script should use the bundle.js file mentioned in the webpack.config.js file:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Webpack React</title>
</head>
<body>
    <div id="app"></div>
    <script src="bundle.js"></script>
</body>
</html>

Babel presets

The correct .babelrc looks like this:

{
  "presets": [
    [
      "@babel/preset-env",
      {
        "useBuiltIns": "entry",
        "corejs": "3.22"
      }
    ],
    ["@babel/preset-react"]
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions