Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

webpack-concat-plugin

hxlniada36.2kISC3.0.0TypeScript support: definitely-typed

Webpack file concatenation.

readme

webpack-concat-plugin

Build Status npm package npm downloads

A plugin to help webpack concat js and inject into html

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.

Install

npm install webpack-concat-plugin --save-dev

for webpack >= 4.0

npm install webpack-concat-plugin@3.0.0 --save-dev

Features

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

Usage

const ConcatPlugin = require('webpack-concat-plugin');

new ConcatPlugin({
    ...see options
    // examples
    uglify: false,
    sourceMap: false,
    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

uglify [boolean | object] default: false

if true the output file will be uglified

or set uglifyjs options to customize the output

sourceMap [boolean] default: false

if true, will output sourcemap

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)
...

TODO

  • <input disabled="" type="checkbox"> add css support
  • <input checked="" disabled="" type="checkbox"> auto inject to html

changelog

Change History

v3.0.0 (2018-06-08)

  • support webpack4.0.0
  • Better hashing. thanks to ddumont
  • Use same location as webpack's other sourcmaps. thanks to ddumont

v2.4.2 (2017-12-15)

  • upgrade schema-utils to 0.4.3 to show schema errors with a better syntax

v2.4.1 (2017-12-15)

  • fix cannot get source map sources correcly. thanks to karlAlnebratt

v2.4.0 (2017-12-13)

  • auto inject to html when html-wepback-plugin inject is not false
  • now support publicPath and outputPath
  • fix other bugs

v2.3.0 (2017-12-12)

  • filesToConcat now support glob syntax
  • add schema
  • now use webpack's enhanced-resolve to solve the module path, and the root path is webpack's context path now.
  • fix other bugs

noted

  • due to the way to find modules has changed, you may need to change your path

v2.2.0 (2017-12-11)

  • fix not outputting sourcemaps when uglify: false, thanks to jaketodaro

v2.1.0 (2017-12-10)

  • don't need to set manifestName option when use webpack-manifest-plugin
  • add support to set hash length

v2.0.0 (2017-12-09)

  • update uglify-js to uglify-es, thanks to tomastrajan
  • feat: add integration tests, very thanks to jiverson
  • Fix "Reduce of empty array with no initial value" error, thanks to akempes
  • support to call from package name, inspired by funcphp
  • fix #27
  • Implement hook from webpack-manifest-plugin 2.0.0-rc.1, fix #22

breaking changes

  • Remove process.env.NODE_ENV fix #24

v1.4.2 (2017-10-21)

  • fix #19; thanks to gosp

v1.4.1 (2017-08-31)

  • Reload file content on each compiler emit; Fixes #7; thanks to subhaze
  • Fix duplicate hash at generated filename; thanks to IndraGunawan

v1.4.0 (2017-08-07)

  • Allow passing on Uglify options (#10); thanks to filipesilva
  • Allow templating fileName (#9); thanks to filipesilva

v1.3.0 (2017-07-07)

  • add uglify option

v1.2.0 (2017-07-03)

  • Only re-emit file during watch if a dependency changed; thanks to subhaze

v1.1.2 (2017-06-27)

  • fix #2

v1.1.1 (2017-06-17)

  • fix #1

v1.1.0 (2017-06-15)

  • refactor using es6

v1.0.0 (2017-06-15)

  • first release