Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
node_modules
coverage
dist
.idea
.DS_Store
.vscode
yarn-debug.log*
yarn-error.log*
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export default {
}
```

**Note**: if you're using any kind of clean/delete plugins, such as [rollup-plugin-del](https://www.npmjs.com/package/rollup-plugin-del),
which remove any of the destination folders, ensure that this plugin is run **after** that plugin, otherwise the copied files might
accidentally be deleted.

### Configuration

There are some useful options:
Expand Down
8 changes: 8 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,16 @@ export default function copy(options = {}) {
const { contents, dest, src, transformed } = copyTarget

if (transformed) {
if (!fs.existsSync(path.dirname(dest))) {
fs.mkdirSync(path.dirname(dest), { recursive: true })
}

await fs.outputFile(dest, contents, restPluginOptions)
} else {
if (!fs.existsSync(path.dirname(dest))) {
fs.mkdirSync(path.dirname(dest), { recursive: true })
}

await fs.copy(src, dest, restPluginOptions)
}

Expand Down