Skip to content

An easy tool compiles and bundles your React app

License

Notifications You must be signed in to change notification settings

jjwong0915/repack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Repack

📦 An easy tool compiles and bundles your React app 📦

Feature

  • Bundle whole application into one JavaScript file
  • Make your JSX and ES2015 scripts work in browser
  • No need for any extra configuraions

Getting Started

  1. Install repack as a global command with npm,

    $ sudo npm install -g @jjwong0915/repack

    or a project dependency if you wan't to use the API.

    $ npm install --save @jjwong0915/repack
  2. Create two files helloWorld.html and reactApp.jsx.

    helloWorld.html:

    <!DOCTYPE html>
    <html>
    <head>
        <title>Hello Repack</title>
    </head>
    <body>
        <div id="container"></div>
        <script src="bundle.js"></script>
    </body>
    </html>

    reactApp.jsx:

    import reactDOM from 'react-dom'; // ES6 Syntax
    
    reactDOM.render(
        <h1>Hello World!</h1>,        // JSX Syntax
        document.getElementById('container')
    );
  3. Compile and bundle reactApp.jsx into bundle.js with repack.

    $ repack reactApp.jsx bundle.js
  4. Open helloWorld.html with your browser and see the magic works.

CLI Usage

Usage: repack [options] <entry> <output>

React developing tool built with Webpack.

Options:

-h, --help        output usage information
-V, --version     output the version number
-p, --production  remove sourcemaps and minimize your scripts
-v, --verbose     output all the information webpack has
-w, --watch       watches all dependencies and recompile on change

Node.js API

  • Import the repack API by

    const repack = require('@jjwong0915/repack');
  • Function repack(config) => compiler

    • Object config {entry, output, production}
      • String entry: The entry point for the bundle. (Required)
      • String output: The file path to output the bundle. (Required)
      • Boolean production: Switch to production mode. (Default: false)
    • Object compiler {run, watch}
      • Function run() => result
        • Promises result: fullfilled with stats when completed.
      • Function watch(handler) => progress
        • Function handler(result): called after a build has been executed. (Optional)
          • Promise result: fullfilled with stats when completed.
        • Promise progress: fullfilled with watcher when no error.

Built With

Contributing

  • Running the tests with npm test
  • Report bugs with github issues
  • New ideas about the project are welcome!!!

License

ISC License

About

An easy tool compiles and bundles your React app

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published