Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/justeat/f-copy-assets
NPM package to copy assets from node_modules to a specified directory
https://github.com/justeat/f-copy-assets
fozzie ui
Last synced: about 1 month ago
JSON representation
NPM package to copy assets from node_modules to a specified directory
- Host: GitHub
- URL: https://github.com/justeat/f-copy-assets
- Owner: justeat
- License: other
- Created: 2017-08-23T11:41:06.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-21T08:05:41.000Z (over 6 years ago)
- Last Synced: 2024-10-30T14:27:24.995Z (about 2 months ago)
- Topics: fozzie, ui
- Language: JavaScript
- Size: 205 KB
- Stars: 1
- Watchers: 42
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# f-copy-assets :bear:
[![npm version](https://badge.fury.io/js/%40justeat%2Ff-copy-assets.svg)](https://badge.fury.io/js/%40justeat%2Ff-copy-assets)
[![Build Status](https://travis-ci.org/justeat/f-copy-assets.svg)](https://travis-ci.org/justeat/f-copy-assets)
[![Coverage Status](https://coveralls.io/repos/github/justeat/f-copy-assets/badge.svg)](https://coveralls.io/github/justeat/f-copy-assets)A module that copies assets from node_modules to a specified destination directory, using promises
## Usage
```js
const copyAssets = require('@justeat/f-copy-assets');const options = {
pkgSrcGlob: 'node_modules/@justeat/*/',
dest: 'assets/',
verbose: true,
logger: gutil.log
};copyAssets(options)
```## Module Options
### `pkgSrcGlob`
default: `"node_modules/*/"`
Glob to match directory (or directories) containing packages from which will be copied if they are found.
### `dest`
default: `"dist"`
The directory to copy files to.
### `verbose`
default: `false`
Whether or not to log the files that are being copied.
### `logger`
default: `console.log`
If `verbose`, the function to use for logging.
## Specifying assets to be copied
There are a few different ways this can be configured.
### Basic
```json
{
"assets": {
"root": "dist/",
"glob": "img/**/*.{png,svg}"
}
}
```All files matching the glob `"dist/img/**/*.{png,svg}"` will be copied into an `img` directory in the `dest` directory.
## Specify a "dest" directory
```json
{
"assets": {
"root": "dist/",
"glob": "img/**/*.{png,svg}",
"dest": "./"
}
}
```All files matching the glob `"dist/img/**/*.{png,svg}"` will be copied into an `img` directory in the root of the project.
## Multiple asset configurations
```json
{
"assets": [
{
"root": "dist/",
"glob": "img/**/*.{png,svg}"
},
{
"root": "src/",
"glob": "templates/**/*",
"dest": "./"
}
]
}
```All files matching the glob `"dist/img/**/*.{png,svg}"` will be copied into an `img` directory in the `dest` directory, _**and**_ all files matching the glob `"src/templates/**/*"` will be copied into a `templates` directory in the root of the project.
## Assets Options
### `root`
Root directory to search for assets. The file structure under `"root"` will be preserved, so in this example, copied assets would be found in `"assets/img/..."`.
### `glob`
Specify a glob pattern to search for assets which should be copied.
### `dest`
Specify the directory that the matched assets should be copied into. This option is not required — it will default to [the `dist` option within the module options](#module-options).