Coder Social home page Coder Social logo

jaid / inject-body-webpack-plugin Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 6.0 4.63 MB

Webpack plugin that injects a custom string into the body of the html-webpack-plugin output.

Home Page: https://github.com/Jaid/inject-body-webpack-plugin

License: MIT License

JavaScript 100.00%
webpack webpack-plugin plugin addon add-on node node-js html html-webpack-plugin html-webpack-plugin-plugin

inject-body-webpack-plugin's Introduction

inject-body-webpack-plugin

License Sponsor inject-body-webpack-plugin
Build status Commits since v1.3.0 Last commit Issues
Latest version on npm Dependents Downloads

Webpack plugin that injects a custom string into the body of the html-webpack-plugin output.

Installation

inject-body-webpack-plugin on npm

npm install --save-dev inject-body-webpack-plugin@^1.3.0

inject-body-webpack-plugin on Yarn

yarn add --dev inject-body-webpack-plugin@^1.3.0

Example

Input

webpack.config.babel.js

import HtmlWebpackPlugin from "html-webpack-plugin"
import InjectBodyPlugin from "inject-body-webpack-plugin"

export default {
  plugins: [
    new HtmlWebpackPlugin({
      templateContent: "<html><body></body></html>"
    }),
    new InjectBodyPlugin({
      content: '<main id=root>Hi!</main>'
    }),
  ],
}

Output

index.html

<html><body><main id=root>Hi!</main></body></html>

Options

Type Default Info
content string <div id=root/> The text that will be injected into the final HTML output.
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.

Development

Development hints for maintaining and improving inject-body-webpack-plugin

Setting up:

git clone [email protected]:jaid/inject-body-webpack-plugin.git
cd inject-body-webpack-plugin
npm install

Testing in production environment:

npm run test

License

MIT License
Copyright © 2021, Jaid <[email protected]> (https://github.com/jaid)

inject-body-webpack-plugin's People

Contributors

actions-user avatar github-actions[bot] avatar jaid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

inject-body-webpack-plugin's Issues

Improper module declaration

Importing the plugin when using TypeScript to write webpack configuration with
import InjectBodyPlugin from 'inject-body-webpack-plugin';
as suggested by the Example section in readme.md yields

error TS2351: This expression is not constructable.
Type 'typeof import("inject-body-webpack-plugin")' has no construct signatures.
by the TypeScript compiler even though if type checking is skipped no error occurs.

I think the problem is with generated module declaration in index.d.ts.
If we replace export class InjectBodyPlugin with export default class InjectBodyPlugin error no longer occurs.

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.