1.4.5 • Published 7 years ago

pack-cli v1.4.5

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

pack-cli

CircleCI

bundle and test client and server side javascript with webpack and mocha without configuration

  • compiles JavaScript (React + ES2017), CoffeeScript, Jade, Pug, JSON and yaml
  • bundles sass, less and css with optional css-modules, images, fonts, videos
  • development with (react) hot reloading
  • minified production bundles
  • unit tests with mocha, enzyme and ES2017
  • browser (ES5 + css prefixes) and nodeJS as build targets

quick start

install

npm install pack-cli --save

add package scripts in package.json

{
  "scripts": {
    "start": "pack -w",
    "build": "pack",
    "test": "pack -t",
    "help": "pack -h"
  }
}

folder structure

- src
  - main.js
  - ( pack.json )
- package.json

the entry point to the application is src/main.js and the root folder src. these can be changed to client/app.js by passing -s client (--src client) and -m app (--main app) to the command line.

within the project folder imports can be done using relative paths (./filename) or absolute paths (/filename). absolute paths get resolved relative within the source directory src. this is useful for config files (/config rather than ../../config) or within stylesheets (/variables.scss rather than ../../variables.scss).

to keep the scripts in the package.json simple, all options can be provided by an additional pack.json file in the source directory. run pack -h to get a list of all possible options.

the production bundle gets written into dist/js/bundle.js and other subfolders (dist/images, dist/css, dist/fonts, dist/media). these defaults can be changed to build/app.js by passing -d build (--dist build) and -b app (--bundle app). to flatten the bundle (no subfolders) use --flatten.

Watch mode

to enable development mode pass -w (--watch). this enables a hot reloading environment in the browser. when used for nodeJS (-n or --node) the watch mode runs the application and restarts it when outdated or crashed. Use NIM (chrome add-on, node instance manager) to access dev-tools.

React

to build a react single page app react mode can be enabled by passing -r (--react) to the app. the entry point to the app (src/main.js) is expected to export a react component as default.

the component gets mounted into a dom element with id render, if no element is found a new div element is created in body and the component gets mounted in there.

when used in watch mode -w the component gets hot reloaded as soon as a file is changed. react-hot-loader is used to preserve state.

css modules

css modules can be enabled by passing -c (--cssmodules) to the command line arguments. css modules are used for .css, .less, .scss files. to prevent a stylesheet from being parsed prepend global to its extension (import './legacy.css'; to import './legacy.global.css';).

global install and help

the package can be installed global by using npm install -g pack-cli. use pack -h to show all available options.

when pack is installed global --init can be used to scaffold a project into the empty current directory. All flags can be used (pack --init -rc for react and css-modules) and get saved in the project.

1.4.5

7 years ago

1.4.4

7 years ago

1.4.3

7 years ago

1.4.2

7 years ago

1.4.1

7 years ago

1.4.0

7 years ago

1.3.12

7 years ago

1.3.11

7 years ago

1.3.10

7 years ago

1.3.9

7 years ago

1.3.8

7 years ago

1.3.7

7 years ago

1.3.6

7 years ago

1.3.5

7 years ago

1.3.4

7 years ago

1.3.3

7 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.4

7 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.1.11

7 years ago

1.1.10

7 years ago

1.1.9

7 years ago

1.1.8

7 years ago

1.1.7

7 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.2.16

7 years ago

0.2.15

7 years ago

0.2.14

7 years ago

0.2.13

7 years ago

0.2.12

8 years ago

0.2.11

8 years ago

0.2.10

8 years ago

0.2.9

8 years ago

0.2.8

8 years ago

0.2.7

8 years ago

0.2.6

8 years ago

0.2.5

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago