Last active
February 28, 2022 16:58
-
-
Save soderlind/e187a6f7e03d08e01d851ff45de41430 to your computer and use it in GitHub Desktop.
Add a banner to build/index.js, when running "wp-scripts build"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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}`, | |
}), | |
], | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I use it here: https://github.com/soderlind/super-admin-all-sites-menu/
wp-scripts build
output: build/index.js