1.0.3 • Published 4 years ago

html-inline-entry-chunk-plugin v1.0.3

Weekly downloads
3
License
ISC
Repository
github
Last release
4 years ago

webpack-versioin node-versioin npm-versioin html-webpack-plugin

html-inline-entry-chunk-plugin

notice: use this with html-webpack-plugin

When useing optimization.splitChunks, obtain all dependent files according to the entrance and synthesize HTML files according to the dependencies.

If it is useful please give the star on the github.(如果有用,请给星! / 役立つ場合は、星をつけてください / 유용하다면 별을주세요.)

Download

    npm install --save-dev html-inline-entry-chunk-plugin

Fast use

  • use in single page
    // webpack plugin config
    module.exports = {
        entry: {
            index: './src/js/index.js'
        },
        plugin: [
            new htmlInlineEntryChunkPlugin(),
            // when useing inlineHtmlEntryChunkPlugin, the chunk param in htmlWebpackPlugin is invalid
            new htmlWebpackPlugin({
                entry: 'index',  // need to be consistent with the entry name
                title: 'test-page',
                template: 'tpl.html',
                chunk: ['chunkName'] //chunk is invalid
            })
        ]
    }
  • use in multi page
    // webpack plugin config
    module.exports = {
        entry: {
            index: './src/js/index.js',
            list: './src/js/list.js'
        },
        plugin: [
            new htmlInlineEntryChunkPlugin(),
            new htmlWebpackPlugin({
                entry: 'index'
            }),
            new htmlInlineEntryChunkPlugin(),
            new htmlWebpackPlugin({
                entry: 'list'
            })
        ]
    }

Options

NameTypeDefaultDescription
inject{Object}{css: 'head', js: 'body'}control the assets of position in HTML
tag{Object}{}Add additional resource tags
tagPriority{Number}0Control the insertion order of entry chunk and other tags
baseJsDir{String}''Control the prefix of script tags in html
baseCssDir{String}''Control the prefix of link tags in html

Example

    module.exports = {
        plugin: [
            new htmlInlineEntryChunkPlugin({
                inject: {
                    js: 'body',
                    css: 'head'
                },
                tagPriority: 1,  // 1: inline custom tag first   0: inline chunk file first
                baseJsDir: '../',
                baseCssDir: '//www.cdn-plugin.com/css/',
                tag: {
                    // Control the corresponding introduction order according to the position in the array
                    head: [
                        'https://cdn.bootcdn.net/ajax/libs/basscss/8.1.0/css/basscss-cp.css',
                        'https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js'
                    ],
                    body: [
                        'https://cdn.bootcdn.net/ajax/libs/animate.css/4.1.0/animate.compat.css',
                        'https://cdn.bootcdn.net/ajax/libs/Chart.js/3.0.0-alpha/Chart.esm.js'
                    ]
                }
            }),
            new htmlWebpackPlugin({
                entry: 'index'
            })
        ]
    }
1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

0.0.17

4 years ago

0.0.16

4 years ago

0.0.15

4 years ago

0.0.14

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.10

4 years ago

0.0.11

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.3

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago