0.1.2 • Published 6 years ago

html-webpack-auto-inject-plugin v0.1.2

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Auto Inject extension for the HTML Webpack Plugin

html-webpack-auto-inject-plugin,auto inject js file to html

Why you need this

Sometimes,I just need require/import a js source inject to html file.ie:flexible.js,some log js,but I have to modify html template file or require/import file that I won't actually exec by code manually.

Feature

Now Support:

  • Auto inject js file
  • Compress js file

Will Support

  • Auto inject css file
  • Do you want by create issue to me

How to use

This plugin require html-webpack-plugin,because listen the event by emit html-webpack-plugin:html-webpack-plugin-before-html-processing.

Installation

You must be running webpack on node 4 or higher

Install the plugin with npm:

$ npm install --save-dev html-webpack-auto-inject-plugin

# for npm > 5
$ npm install --only=dev html-webpack-auto-inject-plugin

Basic Usage

Require the plugin in your webpack config:

const HtmlWebpackAutoInjectPlugin = require('html-webpack-auto-inject-plugin');

Add the plugin to your webpack config as follows:

For now,just support javascript file import,will support css file import in 1.0 version.

All javascript file import config are set in script

options

  • script Array : Accept string for file path and Object for custom config. String:for javascript path.relative or absolute. Object: - path: Like directly set string above config - compress Boolean: compress or not.Use uglify-js.
plugins: [
  new HtmlWebpackPlugin(),
  new HtmlWebpackAutoInjectPlugin({
    script: [
        // relative path
        './path/to/js',
        // absolute path
        '/User/sinoon/code/path/to/js',
        // custom config
        {
            path: './path/to/js',
            compress: true
        }
    ]
  })
]
0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago