GithubHelp home page GithubHelp logo

jordanmkoncz / cra-build-watch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nargonath/cra-build-watch

0.0 0.0 0.0 397 KB

A script for create-react-app that writes development builds to the disk

License: MIT License

JavaScript 100.00%

cra-build-watch's Introduction

cra-build-watch

A script for create-react-app that writes development builds to the disk

semantic-release code style: prettier Commitizen friendly Build Status npm version License: MIT

Disclaimer

The builds resulting from this script are NOT for production environment. They lack various optimizations.

This script is meant as a temporary workaround for create-react-app project based until this feature is built-in into react-scripts. See create-react-app#1070.

This script is inspired by other work related such as: https://gist.github.com/jasonblanchard/ae0d2e304a647cd847c0b4493c2353d4.

Ejection

This tool handles ejected projects but it assumes you did not modify your webpack.config.js file, paths.js and env.js utils. If you did I cannot guarantee that this tool will work.

Why do I need this?

As of now (20/04/2018), create-react-app (more precisely react-scripts) does not allow development builds to be written to the disk because it uses webpackDevServer to serve your build files and folders (for good reasons). The problem is that in some cases you need to have these files written to the disk i.e:

  • Developing browser extensions using React.
  • Incorporating your React application into an existing application.
  • Serving your React app with a dedicated backend.

Prerequisites

Supports react-scripts >= 1.0.x, hence it supports the newest version 3.x.x.

Installation

Add it to your project using npm:

npm install -D cra-build-watch

or using yarn:

yarn add -D cra-build-watch

Usage

Add a new script into your package.json:

{
  "scripts": {
    "watch": "cra-build-watch"
  }
}

Run that script:

npm run watch

with Yarn:

yarn watch

Configuration

By default the script will generate everything into build/ at your project root and remove the public path from webpack's configuration.

If those defaults do not work for you, the script accepts some arguments:

  • -b|--build-path: expects either an absolute or relative path. If a relative path is given it will be prefixed by your project root path.
    • default: yourProjectRoot/build.
  • --react-scripts-version: expects the react-scripts version you are using in your project i.e 2.0.3. If not given it will be implied from your node_modules and if it cannot be implied the version 2.1.2 will be the default. Consider setting it if you ejected and are not using the latest react-scripts version.
  • -p|--public-path: expects a relative URL where / is the root. If you serve your files using an external webserver this argument is to match with your web server configuration. More information can be found in webpack configuration guide.
    • default: "".
  • -v|--verbose: display webpack build output.

cra-build-watch's People

Contributors

nargonath avatar jordanmkoncz avatar looseend avatar alexomanie avatar devxpy 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.