Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

emmercm/metalsmith-include-files

Repository files navigation

metalsmith-include-files

⚠️ This repistory has been moved to metalsmith-plugins. ⚠️

npm Version npm Weekly Downloads

Known Vulnerabilities Test Coverage Maintainability

GitHub 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({
        // 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

About

A Metalsmith plugin to include external files in your build.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published