npm.io
1.0.1 • Published 4 years ago

snowpack-plugin-banner

Licence
ISC
Version
1.0.1
Deps
1
Size
4 kB
Vulns
0
Weekly
0

snowpack-plugin-banner

Add comments to the production asset files (JS/CSS) of your Snowpack build.

This plugin uses the dedent package under the hood, so you don't need to worry about overly-indented files in your final build files. Adding multi-line, indented template string literals is no issue thanks to this.

Install

npm

npm i -D snowpack-plugin-banner

Options

Name Type Value(s) / Default Description
banner string The comment you want adding to your file.
position string top | bottom / top Decide whether to add the comment to the top or bottom of the file.
include array [string] / [] A list of files to add the comment to, relative to your public directory.
exclude array [string] / [] A list of files to ignore, relative to your public directory.

Usage

Add comment to bottom of file, omitting the position property will default the comment to the top.
// snowpack.config.js
module.exports = {
  // ...
  plugins: [
    ['snowpack-plugin-banner', {
      banner: `
        /**
          * Copyright (c) my company 2022
          * LICENSE: MIT
          */
      `,
      position: 'bottom'
    }
  ]
  // ...
}
Only add comment to a subset of files
// snowpack.config.js
module.exports = {
  // ...
  plugins: [
    ['snowpack-plugin-banner', {
      banner: `
        /**
          * Copyright (c) my company 2022
          * LICENSE: MIT
          */
      `,
      include: ['app.js', 'styles.css', 'utils.js']
    }
  ]
  // ...
}
Add to all files, but exclude a subset
// snowpack.config.js
module.exports = {
  // ...
  plugins: [
    ['snowpack-plugin-banner', {
      banner: `
        /**
          * Copyright (c) my company 2022
          * LICENSE: MIT
          */
      `,
      exclude: ['utils.js']
    }
  ]
  // ...
}

Keywords