Skip to content

Commit 3910c13

Browse files
committed
Update mix.copy() docs
1 parent 5c24181 commit 3910c13

File tree

2 files changed

+54
-8
lines changed

2 files changed

+54
-8
lines changed

docs/copying-files.md

+53-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,62 @@
11
# Copying Files
22

3+
4+
- [Basic Usage](#basic-usage)
5+
- [Copy a Single File](#copy-a-single-file)
6+
- [Copy Multiple Files](#copy-multiple-files)
7+
- [Copy a Directory](#copy-a-directory)
8+
- [Copy Files With the Given Extension](#copy-files-with-the-given-extension)
9+
- [Exclude an Extension From Being Copied](#exclude-an-extension-from-being-copied)
10+
11+
### Basic Usage
12+
13+
There might be times when, as part of your build, you need to copy one or more files from one location to another. Mix's `copy()` command makes this a cinch.
14+
15+
#### Copy a Single File
16+
17+
```js
18+
mix.copy('node_modules/foo/bar.css', 'public/css');
19+
```
20+
21+
#### Copy Multiple Files
22+
23+
```js
24+
mix.copy([
25+
'src/foo/one.css',
26+
'src/bar/two.css'
27+
], 'public/css');
28+
```
29+
30+
#### Copy a Directory
31+
32+
A common usecase for this is when you wish to move a set of fonts, installed through NPM, to your public directory.
33+
34+
```js
35+
mix.copy('node_modules/vendor/fonts', 'public');
36+
```
37+
38+
If it provides more clarity, `mix.copyDirectory()` is an alias for `mix.copy()`. The following is identical to the previous example.
39+
40+
```js
41+
mix.copyDirectory('node_modules/vendor/fonts', 'public');
42+
```
43+
44+
Please note that, when providing a directory path as the first argument, the output will retain the original directory structure. If you wish to "flatten" it, provide a wildcard search.
45+
46+
```js
47+
mix.copyDirectory('path/to/dir/**', 'public/output');
48+
```
49+
50+
#### Copy Files With the Given Extension
51+
352
```js
4-
mix.copy(from, to);
5-
mix.copy('from/regex/**/*.txt', to);
6-
mix.copy([path1, path2], to);
7-
mix.copyDirectory(fromDir, toDir);
53+
mix.copy('vendor/lib/tests/**/*.php', 'tests');
854
```
955

10-
From time to time, you'll want to copy one or more files, as part of your build process. No problem; that's a cinch. Use the mix.copy\(\) method to specify the source file or folder, and then your desired destination.
56+
#### Exclude an Extension From Being Copied
1157

1258
```js
13-
mix.copy('node_modules/vendor/acme.txt', 'public/js/acme.txt');
59+
mix.copy('tests/**/!(*.js)', 'public/foo');
1460
```
1561

16-
Upon compilation, the "acme" file will be copied to `public/js/acme.txt`, accordingly. A common use case for this is when you wish to move a set of fonts, installed through NPM, to your public directory.
62+
The above will copy all files except for those that end in `.js`.

docs/readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
### Tasks
3232

33-
- [Copying Files](copying-files.md)
33+
- [Copy Files and Directories](copying-files.md)
3434
- [Concatenation and Minification](concatenation-and-minification.md)
3535

3636
### Helpers and Configuration

0 commit comments

Comments
 (0)