Coder Social home page Coder Social logo

chess-explorer's Introduction

♟️ chess-explorer

Netlify Status

This is a small project for studying and future reference on webpack configuration, where a React project is setup from scratch, without tools like create-react-app. The goal is to create a SPA consuming chess.com public API to search for chess players in the platform. countryflags.io was also use to render the player national flag. The app was deployed and hosted in chess-explorer.netlify.app The app currently looks like this:

What we have here:

  • Babel setup to transpile ES6 and JSX code.

  • Configured webpack to import jsx files as well as scss and image files. Webpack will also link to Babel and bundle the whole application to be deployed.

  • Configured webpack-dev-server and react-refresh-webpack-plugin to improve the development process.


Setting up React dependencies

For creating our React app we'll be using react and react-dom packages (the app will have only one page, so no use really for react-router-dom.

Setting up Babel

Babel related dependencies are @babel/core for Babel base functionalities and @babel/cli to enable command line tools. (-D or --save-dev parameter stands for development only dependency. That is the case because for production we're going to generate a transpiled final version of the code which won't really need Babel.

npm install -D @babel/cli @babel/core

Then we're also going to install two presets (which basically bundles common Babel plugins, we have a nicer longer explanation about this here.

npm install -D @babel/preset-env @babel/preset-react

Next step is to configure Babel, this can be done by creating a file in the project root directory called babel.config.js containing:

module.exports = {
  presets: [
    '@babel/preset-env',
    ['@babel/preset-react',{
      runtime: 'automatic'
    }]
  ]
};

By using the option runtime: 'automatic' we don't need to import React in every React component even if it is not being explicitly. This is a new feature for Babel versions 7.9 and above.

Configuring webpack

Importing jsx files

Importing scss files

Importing images

webpack dev server

fast refresh

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.