UNPKG

2 kBMarkdownView Raw
1# sparrow-packer
2
3web frone-end content pack tool, support multi-pages web app
4
5powered by rollup & postcss
6
7
8
9## Installation
10
11need javascript APIs:
12
13```shell
14npm i sparrow-packer
15```
16
17or take "-g" option to use the CLI tool
18
19```shell
20npm i sparrow-packer -g
21```
22
23
24
25## CLI
26
27run command in the source directory or the project directory that include "src" directory,this tool will try to find the source directory
28
29```shell
30localhost:src user-name$ sprpack
31localhost:project-dir user-name$ sprpack
32```
33
34specify the source directory or the project directory
35
36```shell
37localhost:any-path user-name$ sprpack /Users/user-name/code/project-dir/src
38localhost:any-path user-name$ sprpack /Users/user-name/code/project-dir
39```
40
41specify both the source directory and the target directory
42
43```shell
44localhost:any-path user-name$ sprpack /Users/user-name/code/project-dir/src /Users/user-name/code/project-dir/dist
45```
46
47specify relative directory
48
49```shell
50localhost:project-dir user-name$ sprpack src dist
51```
52
53specify a page
54
55```shell
56localhost:project-dir user-name$ sprpack src/index.html dist/index.html
57```
58
59specify a script entry
60
61```shell
62localhost:project-dir user-name$ sprpack src/index.js dist/app.js
63```
64
65specify a (post)css entry
66
67```shell
68localhost:project-dir user-name$ sprpack src/css/index.pcss dist/css/app.css
69```
70
71clean target directory
72
73```shell
74localhost:project-dir user-name$ sprpack src dist -c(lean)
75```
76
77pack and watch file changes
78
79```shell
80localhost:project-dir user-name$ sprpack src dist -w(atch)
81```
82
83
84
85## Javascript APIs
86
87```javascript
88const { join } = require('path')
89const { pack } = require('../src')
90
91const src = join(__dirname, 'src')
92const dist = join(__dirname, 'dist')
93
94pack(src, dist, {
95 clean: true,
96 watch: true,
97 format: 'iife', // rollup module format, 'iife' by default
98 uglify: true, // false by default,
99 sourcemap: true // false by default
100})
101```
102