1.0.1 • Published 7 years ago

react-power v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

Introduction

Command line toolkit includes full-featured scripts powered by React ecosystem.

Quickly start a web app development with none configuration, or optionally add a minimal config file when needed.

Prerequisite

Require Node.js v7.6 or later. (for async/await supporting)

Getting Started

Creates new work directory.

$ mkdir my-app
$ cd my-app

Intalls react-power with npm or yarn.

$ yarn init
$ yarn add --dev react-power

Adds scripts to package.json.

"scripts": {
  "dev": "react-power dev",
  "build": "react-power build",
  "clean": "react-power clean"
}

Writes some source code.

$ mkdir src
$ echo 'document.getElementById("root").innerHTML = "Hello world!"' > src/index.js
$ echo \
'<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>React Power</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=device-width, initial-scale=1">
  </head>
  <body>
    <div id="root"></div>
  </body>
</html>' \
> src/template.html

Tries running script dev, build, clean.

$ yarn run dev
$ yarn run build
$ yarn run clean

Configuration

Create a file react-power.config.js in root directory. In it, you'll configure like this:

module.exports = {
  input: './src',
  output: './dist',
  publicPath: '/',
  multi: false,
  ignore: /shared/,
  vendor: [],
  externals: {},
  babelrc: {},
  rules: [],
  browserslist: ['last 2 versions', '> 5%', 'ie > 8'],
  cssModules: true,
  hot: true,
  hash: true,
  host: 'localhost',
  port: 3000,
  open: false
}

Options Reference

OptionTypeDefaultDescription
inputString'./src'Where react-power resolve source code.
outputString'./dist'Where react-power output bundles.
publicPathString'/'Specifies the public URL of the output directory when referenced in a browser.
multiBooleanfalseWhether is a multi page application or not.
ignoreRegExp/shared/Ignores the module name using regexp only effective when multi is true.
vendorArraySpecifies the vendor modules to make them seperate from main bundle.
externalsObjectProvides a way of excluding dependencies from the output bundles.
babelrcObjectExtends built-in babel transforming configuration.
rulesArrayExtends built-in loader rules configuration.
browserslistArray'last 2 versions', '> 5%', 'ie > 8'Declare supported environments by performing queries both applied to js and css.
cssModulesBooleantrueWhether enables css modules or not.
hotBooleantrueWhether enables hot module replacement or not.
hashBooleantrueWhether enables hash and chunkhash bundles or not.
hostString'localhost'Local development server host.
portNumber3000Local development server port.
openBooleanfalseWhether open the browser immediately when bundles are finished.

Buit-in Features

babelrc

  • babel-preset-env
  • babel-preset-stage-0
  • babel-preset-react
  • react-hot-loader/babel
  • babel-plugin-transform-runtime

rules

  • babel-loader
  • json-loader
  • sass-loader
  • less-loader
  • url-loader

Examples

See more examples for usage detail.

License

Released under the MIT license.