npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

template-banner-webpack-plugin

v1.1.2

Published

Adds the data of a package from package.json to the top of each generated chunk. (or from any other json or js file)

Downloads

258

Readme

TemplateBannerPlugin

node node

Adds the data of a package from package.json to the top of each generated chunk. (or from any other json or js file)

Install

$ yarn add --dev template-banner-webpack-plugin
# or
$ npm i --save-dev template-banner-webpack-plugin

Usage

Import the plugin module into webpack configuration.

const TemplateBannerPlugin = require('template-banner-webpack-plugin');

Then use this plugin with some options.

new TemplateBannerPlugin(banner)
// or
new TemplateBannerPlugin(options)
new TemplateBannerPlugin({
    banner: `<filename>: <chunk.name> <chunk.ids> <hash> <chunk.hash>
{name} v{version}
(c) 2017-{year} {author}
Released under the {license}.`,
    default(data) {
        return {
            year: (new Date()).getFullYear(),
            license: `${data.license} License`
        };
    },
});

Then output files has template banner like this.

/*!
 * input.js: main 0 add0afa23daa62148cae 9761215c7cb0ac58e442806feccefa72
 * pretty-checkbox-vue v1.1.2
 * (c) 2017-2018 Hamed Ehtesham
 * Released under the MIT License.
 */

If you have discovered a 🐜 or have a feature suggestion, feel free to create an issue on Github.

Options

new TemplateBannerPlugin(options);

Name | Type | Default Value | Description ------------ | ------------- | ------------- | ------------- banner | String | '{name} v{version}' | the banner template as string, to add to the top of each generated chunk; it will be wrapped in a comment
raw | Boolean | false | if true, banner will not be wrapped in a comment default | Object or Function | | it is the data to be available in banner via template. any field that exist here would override the fields of json or js file. if it's a function data would be passed to it as an object like this default(data) then this function can manipulate the data and return the new data path | String | | try to find your current directory or use webpack context to locate your filename and if fails to do that throws error filename | String | 'package.json' | file to use for data could be json or js (should exports (module.exports (commonjs2)) an object or a function that returns an object) test | String or RegExp or Array | | if the argument is a string it will be compared with the whole chunk's filename, string elements in array will do the same include | String or RegExp or Array | | it's not the path; it works just like test
exclude | String or RegExp or Array | | it's not the path; it works just like test but to exclude files instead of including theme

Template

Use {} for all data from default values or json or js file

Use <> for all chunk specific data that is <hash>, <chunk>, <filename>, <basename>, <query>

Note that you can select json or js exported object properties like this: {repository.url} or {keywords[0]}, {keywords[3]}

Note that <chunk> is an object too that you can use its properties like <chunk.name>, <chunk.ids[0]> or <chunk.hash>

for more information about chunk properties see this

Removing all other comments

If you want to remove all other comments, use uglifyjs-webpack-plugin.

for more information about uglifyjs-webpack-plugin options see this

$ yarn add --dev uglifyjs-webpack-plugin
# or
$ npm install --save-dev uglifyjs-webpack-plugin 
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');

and also you must use it after UglifyJSPlugin.

// ...
  plugins: [
    new UglifyJSPlugin(),
    new TemplateBannerPlugin()
  ]
// ...

License

Released under The MIT License. Copyright (c) hamed-ehtesham.

Author

Hamed Ehtesham