Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/koole/netlify-push-webpack-plugin
📦 Generate a Netlify HTTP2 Server Push configuration with Webpack
https://github.com/koole/netlify-push-webpack-plugin
html-webpack-plugin http2 http2-push netlify webpack
Last synced: 3 months ago
JSON representation
📦 Generate a Netlify HTTP2 Server Push configuration with Webpack
- Host: GitHub
- URL: https://github.com/koole/netlify-push-webpack-plugin
- Owner: koole
- License: mit
- Created: 2018-09-13T10:45:10.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-02-11T10:22:42.000Z (almost 2 years ago)
- Last Synced: 2024-10-28T04:07:04.441Z (4 months ago)
- Topics: html-webpack-plugin, http2, http2-push, netlify, webpack
- Language: JavaScript
- Homepage:
- Size: 1.08 MB
- Stars: 7
- Watchers: 3
- Forks: 3
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NetlifyPushWebpackPlugin
Generate HTTP2 Server Push `_headers` file for Netlify using HtmlWebpackPlugin.
For use with Webpack 4 and HtmlWebpackPlugin 4
## Installation
```
npm i netlify-push-webpack-plugin
```or
```
yarn add netlify-push-webpack-plugin
```## Usage
| Option | Type | Description |
| ---------- | ------ | -------------------------------------------------- |
| `filename` | String | Name and path of the generated headers file |
| `headers` | Array | Other headers to be added to the file (optional) |
| `include` | String | Only include 'css', 'js' or 'all' (default: 'all') |## Example
The following config
```js
const HtmlWebpackPlugin = require("html-webpack-plugin");
const NetlifyServerPushPlugin = require("netlify-push-webpack-plugin");module.exports = {
plugins: [
new HtmlWebpackPlugin(),
new NetlifyServerPushPlugin({
filename: "_headers",
headers: [
" X-Frame-Options: DENY",
" Referrer-Policy: strict-origin-when-cross-origin",
"/assets/*",
" Cache-Control: public, max-age:360000"
],
include: "css"
})
]
};
```will result in a headers file looking something like this:
```
/*
Link: ; rel=preload; as=script
Link: ; rel=preload; as=style
X-Frame-Options: DENY
Referrer-Policy: strict-origin-when-cross-origin
/assets/*
Cache-Control: public, max-age:360000
```## Testing
Tests are ran using using Ava with the following command:
```
npm run test
```