UNPKG

2.97 kBMarkdownView Raw
1# parcel-plugin-static-files-copy [![Build Status](https://travis-ci.org/elwin013/parcel-plugin-static-files-copy.svg?branch=master)](https://travis-ci.org/elwin013/parcel-plugin-static-files-copy)
2
3ParcelJS plugin to copy static files from some directory to directory with bundle.
4
5## Install
6
7```
8yarn add parcel-plugin-static-files-copy --dev
9```
10
11## Usage
12
131. Create `static` directory in you project root.
142. Fill it with your static files
153. Run build - and that's all!
16
17## Customization
18
19Beyond the default settings, you can:
20
211. Name of the directory to be copied.
222. Copy multiple directory.
233. Copy different directory based on different output directory.
243. Watch for changes during development (rebuilding when necessary).
25
26### Example
27
28The following configures the plugin to copy all files in `public` to the build directory and watch for changes in all source files (`**` is a deep wildcard).
29
30```json
31// package.json
32{
33 ...
34 "staticFiles": {
35 "staticPath": "public",
36 "watcherGlob": "**"
37 }
38}
39```
40
41### Multiple Static Directories
42
43To copy more than one directory to the build directory, specify `staticPath` as an array. The following copies `public` and `vendor/public`:
44
45```json
46// package.json
47{
48 ...
49 "staticFiles": {
50 "staticPath": ["public", "vendor/public"]
51 }
52}
53```
54
55### Different source of static files based on output directory
56
57To copy different files (from different directories) based on output directory (e.g. `--out-dir dist1` and `--out-dir dist2`) make `staticPath` a object:
58
59```json
60// package.json
61{
62 ...
63 "staticFiles": {
64 "staticPath": [
65 {
66 "outDirPattern": "**/dist1",
67 "staticPath": "static1"
68 },
69 {
70 "outDirPattern": "**/dist2",
71 "staticPath": "static2"
72 }
73 ]
74 },
75}
76```
77
78### Watching for Changes
79
80Parcel can rebuild your bundle(s) whenever changes occur in the static directory. This is disabled by default, but it can be enabled by specifying a glob pattern for files that shoudl be watched.
81
82Note the relative file path is used in matching (not just the file name). To match filenames in deep directories, start with a "globstar" (double star). The plugin uses Node's built-in [Minimatch Library](https://github.com/isaacs/minimatch) for glob matching.
83
84The following watches all XML files in the static directory:
85
86```json
87// package.json
88{
89 ...
90 "staticFiles": {
91 "staticPath": "public",
92 "watcherGlob": "**/*.xml"
93 }
94}
95```
96
97To disable watching, either remove the `"watcherGlob"` key (disabled is the default) or set it to false/null/undefined:
98
99```json
100// package.json
101{
102 ...
103 "staticFiles": {
104 "staticPath": "public",
105 "watcherGlob": false
106 }
107}
108```
109
110## Contribute
111
112You're interested in contributing? Awesome! Fork, make change, commit and create pull request. I'll do my best to merge changes!
113
114## License
115
116[MIT](/LICENSE)