Skip to content

Instantly share code, notes, and snippets.

@soderlind
Last active February 28, 2022 16:58
Show Gist options
  • Save soderlind/e187a6f7e03d08e01d851ff45de41430 to your computer and use it in GitHub Desktop.
Save soderlind/e187a6f7e03d08e01d851ff45de41430 to your computer and use it in GitHub Desktop.
Add a banner to build/index.js, when running "wp-scripts build"
"use strict";
const defaultConfig = require("@wordpress/scripts/config/webpack.config");
const packageJSON = require("./package.json");
const webpack = require("webpack");
const TerserPlugin = require("terser-webpack-plugin");
module.exports = {
...defaultConfig,
module: {
...defaultConfig.module,
rules: [...defaultConfig.module.rules],
},
optimization: {
...defaultConfig.optimization,
minimizer: [
new TerserPlugin({
extractComments: false,
}),
],
},
plugins: [
...defaultConfig.plugins,
new webpack.BannerPlugin({
exclude: /\.php$/,
banner: `${packageJSON.name}
version: ${packageJSON.version}
address: ${packageJSON.homepage}
author: ${packageJSON.author}
license: ${packageJSON.license}`,
}),
],
};
@soderlind
Copy link
Author

soderlind commented Feb 27, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment