GithubHelp home page GithubHelp logo

jacksplwxy / inject-body-compaticity-webpack-plugin Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 19 KB

Webpack plugin that injects a custom string into the body of the html-webpack-plugin output.It is compatible with different versions of WebPack and HtmlWebPackPlugin

License: MIT License

TypeScript 100.00%

inject-body-compaticity-webpack-plugin's Introduction

inject-body-compaticity-webpack-plugin Introduction

A HTML Webpack Plugin that injects a custom string into the body of the html-webpack-plugin output.It is compatible with different versions of WebPack and HtmlWebPackPlugin. (inspired by inject-body-webpack-plugin)


Differences with inject-body-webpack-plugin

  • It is compatible with different versions of WebPack and HtmlWebPackPlugin.
  • It can work according to process.env.NODE_ENV.

Installation

npm i -D inject-body-compaticity-webpack-plugin

Example

Input

webpack.config.js

import HtmlWebpackPlugin from "html-webpack-plugin"
import InjectBodyCompaticityWebpackPlugin from "inject-body-compaticity-webpack-plugin"

export default {
  mode: 'development',
  plugins: [
    new HtmlWebpackPlugin(),
    new InjectBodyCompaticityWebpackPlugin({
      position:'start',
      content: '<script>alert("Hello InjectBodyCompaticityWebpackPlugin!")</script>',
      env: ["development"]
    }),
  ],
}

Output

index.html

<html><body><script>alert("Hello InjectBodyCompaticityWebpackPlugin!")</script></body></html>

Options

Type Default Info
position string start If “start”, the content will be injected as close to the body opening tag as possible. If “end”, the content will be injected as close to the body ending tag as possible.
content string "" The text that will be injected into the final HTML output.
env string[] [] When the value of process.env.NODE_ENV is in the list, the plugin will take effect

inject-body-compaticity-webpack-plugin's People

Contributors

jacksplwxy avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.