GithubHelp home page GithubHelp logo

djds4rce / gulp-bundle Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jonkemp/gulp-bundle

0.0 1.0 0.0 121 KB

Parse build blocks in HTML to concatenate JavaScript and CSS files

License: MIT License

JavaScript 100.00%

gulp-bundle's Introduction

Deprecation Notice

Just use gulp-useref instead. gulp-useref now handles concatenation of files from build blocks, so gulp-bundle is no longer needed.

gulp-bundle Build Status

Parse build blocks in HTML to concatenate JavaScript and CSS files. A minify option is available.

This is not a gulp plugin. It is meant to be used together with gulp-useref to parse the build blocks in the HTML files, bundle those assets and export the files. This makes it easier to bundle components separately, for example Bower files.

Install

Install with npm

npm install --save-dev gulp-bundle

Usage

var gulp = require('gulp'),
    bundle = require('gulp-bundle');

gulp.task('bundle', bundle('./app/*.html'));

With options:

var gulp = require('gulp'),
    bundle = require('gulp-bundle');

gulp.task('bundle', bundle('./app/*.html', {
    appDir: 'app',
    buildDir: 'dist',
    minify: true
}));

With gulp-useref:

var gulp = require('gulp'),
    useref = require('gulp-useref'),
    bundle = require('gulp-bundle');

gulp.task('bundle', bundle('./app/*.html', {
    appDir: 'app',
    buildDir: 'build',
    minify: true
}));

gulp.task('html', function(){
    return gulp.src('./app/*.html')
        .pipe(useref())
        .pipe(gulp.dest('build/'));
});

gulp.task('build', ['bundle', 'html']);

The build block syntax is build:type path/filename. Valid types are js and css.

<html>
<head>
    <!-- build:css css/combined.css -->
    <link href="css/one.css" rel="stylesheet">
    <link href="css/two.css" rel="stylesheet">
    <!-- endbuild -->
</head>
<body>
    <!-- build:js scripts/combined.js -->
    <script type="text/javascript" src="scripts/one.js"></script>
    <script type="text/javascript" src="scripts/two.js"></script>
    <!-- endbuild -->
</body>
</html>

API

bundle(pattern[, options])

Pattern should be the path to your HTML files.

pattern

Type: String

Pattern to be matched.

options

Type: Object

Options to pass to node-glob.

options.appDir

Type: String
Default: app

Where to find the files.

options.buildDir

Type: String
Default: dist

Where to put the files.

options.minify

Type: Boolean
Default: true

Minifies CSS and JavaScript files.

options.minifyCss

Type: Object
Default: {}

Options to pass to gulp-minify-css. Check the documentation to see the options.

options.minifyJs

Type: Object
Default: {}

Options to pass to gulp-uglify. Check the documentation to see the options.

License

MIT © Jonathan Kemp

gulp-bundle's People

Contributors

djds4rce avatar jonkemp avatar

Watchers

 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.