GithubHelp home page GithubHelp logo

grantbartlett / react-typescript-webpack-starter Goto Github PK

View Code? Open in Web Editor NEW
83.0 5.0 29.0 1.32 MB

A starter project for using React, TypeScript, SCSS using Webpack 5.

Home Page: https://grant-bartlett.com/blog/react-typescript-webpack-starter

License: MIT License

TypeScript 14.96% HTML 2.70% JavaScript 74.94% SCSS 7.39%
react typescript webpack scss webpack-template template-repository webpack5 javascript terserplugin sass-loader

react-typescript-webpack-starter's Introduction

logo

React TypeScript Webpack Starter

A starter project for using React, TypeScript, SCSS and Webpack.

Features

  • Webpack 5 + HMR
  • TypeScript + React 18
  • SCSS + Autoprefixing

🚀 Getting Started

Get up and running with these simple steps:

  1. Clone the project
  2. Run npm install
  3. Run npm run dev

Class & Functional stubs

In the master branch you can find the class based starter. In the branch functional you can find the functional based starter.

Configuration

Optional configuration for the project can be done in the following files below.

Open env.config.js and you will see the default configuration for the project.

Config Description
.browerslistrc Open .browserslist to configure Browser support for TypeScript + SCSS compiliation. Read more here about Browerslist. Defaults are set for last 2 versions, > 1% and IE 11.
outputConfig.destPath The folder in which you want your app to compile to. By default this is dist.
entryConfig Webpack Entry points, by default this will look for the TypeScript + SCSS entry point files. More info on Entry points here
copyPluginPatterns.patterns Configure folders you want copied over when compiling your app. Useful to copy over entire folder structures of images or fonts.
devServer Configure the Webpack development server. Enable https, specify a particular port, or host. More information on these options here
scssConfig.destFileName Specify the output for your css. E.g css/app.css
terserPluginConfig Full Terser config can be found here.

Images, Fonts and output

Here's an example of the default generated output to our dist folder.

- index.html
-- js
-- css
-- fonts
---- some-font-file.woff
-- images
---- path-to-example-image.jpg
  • By default, fonts and images are copied to the dist folder.
  • To include a reference to an image or font, it should be relative to where your css would output.

For example:

stylesheets/some-folder/some-file-somewhere.scss

.example {
    background-image: url("../images/path-to-image-example.jpg");
}

@font-face {
    font-family: "Example-font";
    src: url("../fonts/some-font-file.woff");
}

Would output to the folder css/app.css

- index.html
-- js
-- css
---- app.css
-- fonts
---- some-font-file.woff
-- images
---- path-to-example-image.jpg

Development

npm install
npm run dev

Production

Note: This will compile to a dist folder.

npm run build

Build tools

  • React - JavaScript library for building user interfaces.
  • TypeScript - TypeScript is a superset of JavaScript that compiles to clean JavaScript.
  • Webpack 5 - App bundler for JavaScript.
  • SCSS - Preprocessor for SCSS to CSS.

📝License

This project is licensed under the MIT License - see the LICENSE.md file for details

react-typescript-webpack-starter's People

Contributors

dave-grix avatar dependabot[bot] avatar grantbartlett avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

react-typescript-webpack-starter's Issues

Small error in webpack.config.js

Webpack config has a small error that stops compile when freshly pulled.

        app: ['./src/app.ts'],
        vendor: ['react', 'react-dom']
    },

should be

        app: ['./src/App.ts'],
        vendor: ['react', 'react-dom']
    },

Functional components

I like the simplicity of this starter kit but would like to change to functional components instead of class component. I tried changing the components from class components to functional components but it seems to not render the same.

Example: App.ts

const Component = () =>

HELLO
;

ReactDOM.render(, document.getElementById("app"));

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.