Skip to content

Instantly share code, notes, and snippets.

@kevinSuttle
Created October 12, 2016 16:50
Show Gist options
  • Save kevinSuttle/6d3659076f0dda9010659748ed12a283 to your computer and use it in GitHub Desktop.
Save kevinSuttle/6d3659076f0dda9010659748ed12a283 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