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