Skip to content

Instantly share code, notes, and snippets.

@beardlessman
Forked from kevinSuttle/webpack.banner.js
Created April 17, 2018 04:50
Show Gist options
  • Save beardlessman/c6b5a465b2713f2bca55bfe681e6c4d6 to your computer and use it in GitHub Desktop.
Save beardlessman/c6b5a465b2713f2bca55bfe681e6c4d6 to your computer and use it in GitHub Desktop.
Webpack auto-injecting banner into each file
const pkg = require('./package.json');
const moment = require('moment');
const localTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone
const timeStamp = moment().format('LLLL');
const banner = `
Generated on ${timeStamp} - ${localTimeZone}
Description: ${pkg.description}
Package: ${pkg.name}
Version: v${pkg.version}
Contributors: ${pkg.contributors.map(function(contributor){ return contributor})}
Source: ${pkg.repository.url}
Docs: ${pkg.homepage}
License: ${pkg.license}
Any questions, suggestions, or problems? Feel free to file an issue at:
${pkg.bugs}
Notice:
Do NOT edit this file below this point, any changes will be overwritten.
`;
const webpack = require('webpack');
const path = require('path');
// ..
plugins: [
new webpack.BannerPlugin({banner: banner}),
],
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment