Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kagawagao/html-webpack-inject-plugin
inject external tag to html
https://github.com/kagawagao/html-webpack-inject-plugin
external html plugin webpack webpack-plugin
Last synced: 3 months ago
JSON representation
inject external tag to html
- Host: GitHub
- URL: https://github.com/kagawagao/html-webpack-inject-plugin
- Owner: kagawagao
- License: mit
- Created: 2018-01-26T03:55:06.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-07T09:53:55.000Z (4 months ago)
- Last Synced: 2024-10-10T00:06:24.050Z (4 months ago)
- Topics: external, html, plugin, webpack, webpack-plugin
- Language: TypeScript
- Homepage:
- Size: 1.74 MB
- Stars: 11
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# html-webpack-inject-plugin
[![node](https://img.shields.io/node/v/html-webpack-inject-plugin.svg)](https://www.npmjs.com/package/html-webpack-inject-plugin)
[![npm](https://img.shields.io/npm/v/html-webpack-inject-plugin.svg)](https://www.npmjs.com/package/html-webpack-inject-plugin)
[![license](https://img.shields.io/npm/l/html-webpack-inject-plugin.svg)](https://github.com/kagawagao/html-webpack-inject-plugin/blob/master/LICENSE)
[![Build Status](https://travis-ci.org/kagawagao/html-webpack-inject-plugin.svg?branch=master)](https://travis-ci.org/kagawagao/html-webpack-inject-plugin)
[![Standard - JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](http://standardjs.com/)inject external tag to html
## Installation
```bash
npm install --save-dev html-webpack-inject-plugin
```## Usage
Require the plugin in your webpack config
```javascript
import HtmlWebpackInjectPlugin from 'html-webpack-inject-plugin'
// or
const HtmlWebpackInjectPlugin = require('html-webpack-inject-plugin').default
```Add the plugin to your webpack config as follows
```javascript
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html'
}),
new HtmlWebpackPlugin({
filename: 'other.html'
}),
new HtmlWebpackInjectPlugin({
externals: [
{
tagName: 'script',
attributes: {
src: 'common-script.js',
type: 'text/javascript'
}
},
{
tagName: 'script',
attributes: {
src: 'only-inject-to-other-script.js',
type: 'text/javascript'
},
include: ['other.html']
}
],
prepend: true // default is false
})
]
```## Options
- `externals: []`: external HTMLTagObject which you want to add
- `prepend`: insert before parent first child