Skip to content

Commit 81c798d

Browse files
committed
update readme
1 parent add513a commit 81c798d

File tree

4 files changed

+70
-1
lines changed

4 files changed

+70
-1
lines changed

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
node_modules
2+
3+
assets

README.md

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,68 @@
1-
# gatsby-plugin-copy-files-enhanced
1+
# gatsby-plugin-copy-files-enhanced [![npm](https://img.shields.io/npm/v/gatsby-plugin-copy-files-enhanced.svg)](https://npmjs.com/package/gatsby-plugin-copy-files-enhanced) [![npm](https://img.shields.io/npm/dm/gatsby-plugin-copy-files-enhanced.svg)](https://npmjs.com/package/gatsby-plugin-copy-files-enhanced)
2+
3+
You can use this plugin to copy files in your Gatsby project. Specify absolute `source` path and relative `destination` path using plugin options.
4+
5+
#### What's different from `gatsby-plugin-copy-files`
6+
7+
- In `gatsby-plugin-copy-files` you should specify destination and you have no option to copy to multiple direcotries **in one go**. `gatsby-plugin-copy-files-enhanced` enables you to wildcard your destination, so that you can easily copy files.
8+
9+
- This plugin has to option to **overwrite or not** your destination direcotry simply using `purge` plugin option.
10+
11+
12+
#### Plugin options
13+
14+
| Option | Description |
15+
|:----------|:---------|
16+
|`source` |Absolute path of the source (eg: `${__dirname}/path`)|
17+
|`destination`|Relative path to destination within `public/` direcotry </br> You can add `/*/` inside destination path to wildcard destination lookup </br> *Refer to [graphical explanation](#graphical-explanation) for better understanding*
18+
|`purge` |Overwrite destination. `false` by default|
19+
20+
#### Important
21+
This plugin should be used with `gatsby-source-filesystem`
22+
23+
#### Eample
24+
``` js
25+
{
26+
resolve: 'gatsby-plugin-copy-files-enhanced',
27+
options: {
28+
source: `${__dirname}/src/reportTemplate` ,
29+
destination: '/reports/*/',
30+
purge: true,
31+
}
32+
}, {
33+
resolve: 'gatsby-plugin-copy-files-enhanced',
34+
options: {
35+
source: `${__dirname}/src/images` ,
36+
destination: '/containers/*/images',
37+
purge: false,
38+
}
39+
}
40+
```
41+
42+
#### Graphical explanation
43+
44+
Let's consider that you have a `template.js` file that you need to copy to all reports within `public/reports/` direcotry and you are not sure of report names and how many would be there.
45+
46+
47+
<img src="assets/start.png" width="350">
48+
49+
50+
In such case you can wildcard the destination path so that you can easily copy `template.js` to all direcotries with `public/reports/`
51+
52+
<img src="assets/end.png" width="350">
53+
54+
55+
##### Simply use this code to get this done
56+
``` js
57+
{
58+
resolve: 'gatsby-plugin-copy-files-enhanced',
59+
options: {
60+
source: `${__dirname}/src/template/` ,
61+
destination: '/reports/*/',
62+
purge: true,
63+
}
64+
}
65+
```
66+
67+
<i>Inspired by `gatsby-plugin-copy-files` </i> <3
68+

assets/end.png

56.2 KB
Loading

assets/start.png

30.7 KB
Loading

0 commit comments

Comments
 (0)