GithubHelp home page GithubHelp logo

isabella232 / webpack-concat-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from widgetworks/webpack-concat-plugin

0.0 0.0 0.0 614 KB

a plugin to help webpack to concat file and inject to html

Home Page: https://github.com/hxlniada/webpack-concat-plugin

JavaScript 96.19% HTML 3.81%

webpack-concat-plugin's Introduction

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 [email protected] --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

  • add css support
  • auto inject to html

webpack-concat-plugin's People

Contributors

ddumont avatar filipesilva avatar gosp avatar hxlniada avatar indragunawan avatar jiverson avatar karlalnebratt avatar mrusselltombras avatar subhaze avatar tomastrajan avatar xcatliu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.