@justeat/f-copy-assets

1.1.0 • Public • Published

f-copy-assets 🐻

npm version Build Status Coverage Status

A module that copies assets from node_modules to a specified destination directory, using promises

Usage

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

{
  "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

{
  "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

{
  "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.

Readme

Keywords

Package Sidebar

Install

npm i @justeat/f-copy-assets

Weekly Downloads

10

Version

1.1.0

License

Apache-2.0

Unpacked Size

14.6 kB

Total Files

7

Last publish

Collaborators

  • ilia.chikmarev
  • fidel.montesino
  • anastasiia.horban
  • raouf.sawehli
  • mmakwe-onyeka
  • gregory.palaci
  • arielfdr
  • dawidchar
  • roberto.santana
  • lizzie.turney
  • davidpn.11
  • dandel10n
  • mwh1989
  • kevinrodrigues
  • fozzie-bot
  • ashleynolan
  • simonsje
  • xander-marjoram
  • sergii.semenkiv
  • thomaswilliammcclean
  • benrwhite
  • robertellison
  • zlatin.ivanov
  • joshuang2332
  • oliversweb
  • andymayje
  • jamieomaguire
  • adammorr
  • lsphillips