You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

html-inline-source-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-inline-source-webpack-plugin

🔧A webpack plugin to inline source in html, wrapper of inline-source.

1.1.0
latest
Source
npmnpm
Version published
Weekly downloads
23
2200%
Maintainers
1
Weekly downloads
 
Created
Source

npm npm npm bitHound Overall Score bitHound Dependencies bitHound Code

html-inline-source-webpack-plugin

🔧A webpack plugin to inline source in html, wrapper of inline-source.

Env

  • Node - v4.7.0
  • npm - 2.15.11
  • webpack - ^1.14.0

Install

$ npm install html-inline-source-webpack-plugin --save-dev

Usage

webpack.config.js

// webpack.config.js
let HtmlInlineSourceWebpackPlugin = require('html-inline-source-webpack-plugin');

module.exports = {
    /* Your config */
    plugins : [
        /* ... */
        new HtmlInlineSourceWebpackPlugin(),
    ],
};

index.html

<!DOCTYPE html>
<html>
<head>
    <title> index </title>
    <link inline href="css/index.css" rel="stylesheet">
</head>
<body>
    <script inline src="js/index.js" charset="utf-8"></script>
</body>
</html>

Notice

<script inline src="js/index.js" charset="utf-8"></script>
  • Use inline attribute to inline source;
  • Ensure src or href is linked to a correct file.

Options

Default option

new HtmlInlineSourceWebpackPlugin()

Custom option

This option would apply to all files.

new HtmlInlineSourceWebpackPlugin({
    option : {
        compress : false,
        rootpath : path.resolve('./dist'),
    },
})

Custom option for different file

Use test to let different option apply to different files.

new HtmlInlineSourceWebpackPlugin([
    {
        test : /\bindex\.html$/,
        option : {
            ignore : 'script',
            rootpath : path.resolve('./dist'),
        },
    },
    {
        test : /\bexample\.html$/,
        option : {
            ignore : 'css',
            rootpath : path.resolve('./dist'),
        },
    },
    {
        /* This option would apply to the rest files */
        option : {
            ignore : ['script', 'css'],
            rootpath : path.resolve('./dist'),
        },
    },
])

More option

see here.

Callback

new HtmlInlineSourceWebpackPlugin(function () {
    console.log('inline source done!');
})
/* or */
new HtmlInlineSourceWebpackPlugin({
    /* option */
}, function () {
    console.log('inline source done!');
})

License

MIT

Keywords

webpack

FAQs

Package last updated on 19 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts