# pillar-pack

> > Convention is larger than configuration

Latest version **1.4.0** (published 2018-08-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install pillar-pack
pnpm add pillar-pack
yarn add pillar-pack
bun add pillar-pack
```

Provides the command `pillar-pack`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.0 |
| Published | 2018-08-19 |
| First published | 2018-08-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 266.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Maintainers | ymblender |

## Links

- npm: https://www.npmjs.com/package/pillar-pack
- Repository: https://github.com/ymzuiku/pillar-pack
- Homepage: https://github.com/ymzuiku/pillar-pack#readme
- Issues: https://github.com/ymzuiku/pillar-pack/issues
- npm.io page: https://npm.io/package/pillar-pack

## Dependencies (3)

- [fs-extra](https://npm.io/package/fs-extra.md) ^7.0.0
- [browser-sync](https://npm.io/package/browser-sync.md) ^2.24.6
- [parcel-bundler](https://npm.io/package/parcel-bundler.md) ^1.9.7

## Recent versions

- 1.4.0 (latest) — 2018-08-19
- 1.3.9 — 2018-08-19
- 1.3.8 — 2018-08-12
- 1.3.7 — 2018-08-11
- 1.3.6 — 2018-08-11
- 1.3.5 — 2018-08-11
- 1.3.4 — 2018-08-11
- 1.3.3 — 2018-08-05
- 1.3.2 — 2018-08-05
- 1.3.1 — 2018-08-05
- 1.3.0 — 2018-08-04
- 1.2.9 — 2018-08-04
- 1.2.8 — 2018-08-04
- 1.2.7 — 2018-08-04
- 1.2.6 — 2018-08-04
- … 9 more at https://npm.io/package/pillar-pack/versions

## README

# Real `Zero config` package tool 
### Based on `Brower-sync` and `Parcel`

> Convention is larger than configuration

# [中文文档](README-CN.md)

## Why use this?

In React Project, Parcel need install `babel-*` packages, and need config `.babelrc`. And sometimes `Hot Reload` fail.
Parcel native don't have copy assets feature. So, we have this package. It's juset over parcel, wrapped up in a layer candy.

## Install

```sh
$ npm i -g pillar-pack
```

## Create a `React` project from zero

Create project
```
$ mkdir your-project
$ cd your-project
$ npm init -y
$ mkdir public src
$ touch public/index.html src/index.js
$ yarn add react react-dom
```

Now, your project frame like this, it's a defalut `React` project frame

```sh
-- public
  - index.html
-- src
  - index.js
-- package.json
```

set public/index.html

```html
<!DOCTYPE html>
<html lang="en">

<body>
  <div id="root"></div>
  <script src="bundle-rename.js"></script>
</body>

</html>
```

set src/index.js

```js
import React from 'react';
import ReactDOM from 'react-dom';

class App extends React.Component {
  state = {
    num: 0,
  };
  addNum = () => {
    this.setState({ num: this.state.num + 1 });
  };
  render() {
    return (
      <div>
        <h1>Hello pillar-pack</h1>
        <h2>{this.state.num}</h2>
        <button onClick={this.addNum}>Add Num</button>
      </div>
    );
  }
}

ReactDOM.render(<App />, document.getElementById('root'));
```

**Start:**

```sh
$ pillar-pack -s src/index.js -o build -c public
```

The project is start:

![](.imgs/2018-08-04-13-48-36.png)

### That's all you have to do, they are do this:

1.  If no have `babel-*` packages, auto install `babel-*` packages
2.  create `.babelrc, .postcssrc` file, and add config in it. support css, less, scss
3.  Source file from `src/index.js` or `src/index.ts`
4.  Bundle put out dir to `build`
5.  Copy `public` dir to out dir
6.  Replace in `public/index.html` string of `bundle-rename.js` to real bundle.js
7.  Use `brower-sync` start server, and replace `parcel-hmr` reload page
8.  Use system brower open page

## Default project frame

```sh
-- public
  - index.html
-- src
  - index.js
-- package.json
```

If your project is defalut `React` project frame (above paragraphs), your can just use this:

```sh
$ pillar-pack
```

---

Usually, you don't need to continue reading,unless you need to custommize some special configurations.

## Custom configuration

You can add params to change config:

```js
-s : source file
-o : set out dir
-c, --copy : set copy dir to outDir, defalut ./public
init : Install babel-* in your project
--dll : only pack js to one dll.js
--prod : use prod mode, only build
--cors : is use brower cors
--open : is open brower
--no-reload : set brower-sync no reload
--hmr : open hmr, defalut close
--html : set dev server html, default public/index.html
--rename : change fix bundleName, defalut bundle-rename.js
--no-copy : no copy public dir
--scss : install scss package
--cover-babel : set cover babel file
--no-babel : set no create .babelrc
--source-map : true | false, defalut true
--server : only use server
--version : cat version
--help : help list
--help-cn : Chinese help list
```

## Example

**Install package**

```sh
$ pillar-pack init
```

**change source .js and server port**

```sh
$ pillar-pack -s src/app.js --port 4100
```

**Other custom example:**

1.  Use source file in `lib/index.js`
2.  Copy `lib/assets`
3.  Bundle out to `build-prod`
4.  Change `index.prod.html`
5.  Don't use sourceMap

```sh
$ pillar-pack \
  -s lib/index.js \
  -c lib/assets  \
  -o build-prod \
  --html index.prod.html \
  --source-map false \
  --prod
```

---
_Source: https://npm.io/package/pillar-pack · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
