Code Monkey home page Code Monkey logo

cra-preact's Introduction

create react app + preact = ๐Ÿ’–

Love the CRA bootstrap? Hate big bundle sizes?

npm i -D cra-preact
# or
yarn add --dev cra-preact

Write your code as if you weren't using preact, continue importing react.

usage

Replace your build, start and test scripts

"scripts": {
- "start": "react-scripts start",
- "build": "react-scripts build",
- "test": "react-scripts test",
+ "start": "cra-preact start",
+ "build": "cra-preact build",
+ "test": "cra-preact test",
  "eject": "react-scripts eject"
}

Cool, done. Now watch the bundle size go down.

bundle size drop porn

initial CRA bootstrap

initial app

medium size real-world production project

middle size

disclaimer

While rare, problems may occur.

  • Please be aware that cra-preact is using preact's compatibility layer (preact/compat) and issues with it should be directed to preact's repo
  • Make sure to develop and test with cra-preact to catch incompatibilities during development
  • This project requires react-scripts v3+
  • It is NOT recommended to plug this into existing projects just as a build script. Incompatibilities will most likely surface during runtime, not compile time
  • Because it relies on fine details in react-scripts any minor upgrade of it might be a breaking change for cra-preact
  • While it works with npm, there are no tests available for npm. Because npm link and npm install don't respect peer dependencies

This whole project was inspired by this github comment.

cra-preact's People

Contributors

imgbotapp avatar shilangyu avatar

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.