Coder Social home page Coder Social logo

pillar-pack's Introduction

Real Zero config package tool

Based on Brower-sync and Parcel

Convention is larger than configuration

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

$ 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

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

set public/index.html

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

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

</html>

set src/index.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:

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

The project is start:

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

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

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

$ 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:

-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

$ pillar-pack init

change source .js and server port

$ 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
$ pillar-pack \
  -s lib/index.js \
  -c lib/assets  \
  -o build-prod \
  --html index.prod.html \
  --source-map false \
  --prod

pillar-pack's People

Stargazers

Zi Cheng avatar Jerry.Luo avatar Pillar Liang avatar

Watchers

James Cloos avatar Pillar Liang avatar

Forkers

ityak

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.