@mcler/webpack-concat-plugin

    4.1.3 • Public • Published

    webpack-concat-plugin

    A plugin to help webpack concat js and inject into html. Forked from hxlniada's plugin

    Why

    Webpack is really powerful. However, when I want to concat the static files and inject into html without webpack JSONP code wrapper, it seems impossible to do that without other tool's help.

    Features

    • Concat
    • Inject to html(with html-webpack-plugin)

    Usage

    const ConcatPlugin = require('@mcler/webpack-concat-plugin');
    
    new ConcatPlugin({
        ...see options
        // examples
        name: 'result',
        outputPath: 'path/to/output/',
        fileName: '[name].[hash:8].js',
        filesToConcat: ['jquery', './src/lib/**', './dep/dep.js', ['./some/**', '!./some/excludes/**']],
        attributes: {
            async: true
        }
    });

    Options

    name [string] default: "result"

    it's useful when you want to inject to html-webpack-plugin manully

    publicPath [string|boolean] default: webpack's publicPath

    if set, will be used as the public path of the script tag.

    if set to false, will use relativePath.

    outputPath [string]

    if set, will be used as the output directory of the file.

    fileName [string] default: [name].js

    if set, will be used as the output fileName

    filesToConcat [array] required

    supported path patterns:

    • normal path
    • npm packages
    • glob

    injectType ["prepend"|"append"|"none"] default: "prepend"

    how to auto inject to html-webpack-plugin(only if html-webpack-plugin set inject option not to be false)

    attributes [object]

    if set, will be used as the extra attributes of the script tag.

    Examples

    Inject to html by hand

    doctype html
    ...
        script(src=htmlWebpackPlugin.files.webpackConcat.flexible)
    ...
    

    Install

    npm i @mcler/webpack-concat-plugin

    DownloadsWeekly Downloads

    539

    Version

    4.1.3

    License

    ISC

    Unpacked Size

    32 kB

    Total Files

    7

    Last publish

    Collaborators

    • mcler