3.0.2 • Published 12 months ago

metalsmith-include-files v3.0.2

Weekly downloads
3
License
GPL-3.0-or-later
Repository
github
Last release
12 months ago

metalsmith-include-files

npm: version npm: downloads

Snyk: vulnerabilities codecov: coverage license

A Metalsmith plugin to include external files in your build.

A common use case is wanting to include JavaScript, CSS, or font files from an installed NPM package such as bootstrap.

Installation

npm install --save metalsmith-include-files

JavaScript Usage

const Metalsmith = require('metalsmith');
const include    = require('metalsmith-include-files');

Metalsmith(__dirname)
    .use(include({
        directories: { /* ... */ }
        // other options here
    }))
    .build((err) => {
        if (err) {
            throw err;
        }
    });

Options

directories (required)

Type: object

A dictionary where the keys are Metalsmith build output directories, and the values are an array of micromatch patterns for files on your filesystem.

Example structure:

{
  "directories": {
    "[output directory 1]": [
      "[micromatch pattern 1]",
      "[micromatch pattern 2]"
    ],
    "[output directory 2]": [
      "[micromatch pattern 3]",
      "[micromatch pattern 4]"
    ]
  }
}

overwrite (optional)

Type: boolean Default: false

Whether existing files in the Metalsmith build output can be overwritten or not. An exception will be raised if the option is false and there is a duplicate filename.

Example

To include a number of static assets from jquery, bootstrap, and @fortawesome/fontawesome-free in your output files:

const include = require('metalsmith-include-files');

Metalsmith(__dirname)
    .use(include({
        directories: {
            'static/css': [
                './node_modules/bootstrap/dist/css/bootstrap.min.css',
                './node_modules/@fortawesome/fontawesome-free/css/all.min.css'
            ],
            'static/js': [
                './node_modules/jquery/dist/jquery.slim.js',
                './node_modules/bootstrap/dist/js/bootstrap.min.js'
            ],
            'static/webfonts': [
                './node_modules/@fortawesome/fontawesome-free/webfonts/*'
            ]
        }
    }))

Changelog

Changelog

3.0.2

12 months ago

3.0.1

12 months ago

1.0.2

1 year ago

1.1.0

1 year ago

3.0.0

1 year ago

2.0.0

1 year ago

1.0.1

2 years ago

1.0.0

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.10

3 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago