https://github.com/mraerino/html-webpack-plugin-single-entry
https://github.com/mraerino/html-webpack-plugin-single-entry
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/mraerino/html-webpack-plugin-single-entry
- Owner: mraerino
- Created: 2019-05-17T23:27:59.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2019-05-18T00:09:19.000Z (almost 6 years ago)
- Last Synced: 2025-03-25T02:41:37.058Z (about 2 months ago)
- Language: JavaScript
- Size: 53.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Entry filter plugin for `html-webpack-plugin`
This plugin filters chunks included in the html file generated by `html-webpack-plugin` by the name of an entry.
## Install
```sh
npm install --save-dev html-webpack-plugin-single-entry
```## Use
`webpack.config.js`
```js
const HTMLWebpackPlugin = require('html-webpack-plugin');
const HTMLWebpackPluginSingleEntry = require('html-webpack-plugin-single-entry');module.exports = {
entry: {
main: './main.js',
other: './other.js',
}
...
plugins: [
new HTMLWebpackPlugin(),
new HTMLWebpackPluginSingleEntry({
entry: 'main',
}),
],
...
}
```This example will only include the chunks required by the `main` entrypoint into the html file.
### Use with multiple index files
`webpack.config.js`
```js
const HTMLWebpackPlugin = require('html-webpack-plugin');
const HTMLWebpackPluginSingleEntry = require('html-webpack-plugin-single-entry');module.exports = {
entry: {
main: './main.js',
second: './second.js',
other: './other.js',
}
...
plugins: [
new HTMLWebpackPlugin({
filename: 'main.html',
}),
new HTMLWebpackPluginSingleEntry({
filename: 'main.html',
entry: 'main',
}),
new HTMLWebpackPlugin({
filename: 'second.html',
}),
new HTMLWebpackPluginSingleEntry({
filename: 'second.html',
entry: 'second',
}),
],
...
}
```This example will include the respective assets in the selected html files.