Coder Social home page Coder Social logo

markovchainmontecarlo / gulp-split-files Goto Github PK

View Code? Open in Web Editor NEW

This project forked from petterboozegunk/gulp-split-files

0.0 0.0 1.0 421 KB

A gulp plugin for manually splitting a set of files into even more files.

License: MIT License

JavaScript 35.61% HTML 64.39%

gulp-split-files's Introduction

gulp-split-files

A gulp plugin for splitting a file by count, by size or by logic inside the file

Use

Options fileSize: number in bytes fileCount: number

Examples:

const gulp = require("gulp");
const splitFiles = require("gulp-split-files");

//creates 15 files of equal size (last file with the remainder)
gulp.task("split", function () {
    return gulp.src("superMegaBigCss.css")
    .pipe(splitFiles({fileCount: 15}))
    .pipe(gulp.dest("path/to/dest"));
});

//divides the file into 150k chunks with as many files as necessary
gulp.task("split", function () {
    return gulp.src("superMegaBigCss.css")
    .pipe(splitFiles({fileSize: 1500000}))
    .pipe(gulp.dest("path/to/dest"));
});

//divides the file into 150k chunks with a maximum of 15 files. The 15th file will contain
//the remainder of the bytes
gulp.task("split", function () {
    return gulp.src("superMegaBigCss.css")
    .pipe(splitFiles({fileSize: 1500000, fileCount: 15}))
    .pipe(gulp.dest("path/to/dest"));
});


//passing no arguments will analyze the file for internal logic for how to split the file. Details below.
gulp.task("split", function () {
    return gulp.src("superMegaBigCss.css")
    .pipe(splitFiles())
    .pipe(gulp.dest("path/to/dest"));
});

superMegaBigCss.css content:

[lots of css stuff]
/*split*/
[lots more css stuff]
/*split*/
[even more css stuff]

In your gulpfile:

const gulp = require("gulp");
const splitFiles = require("gulp-split-files");

gulp.task("split", function () {
    return gulp.src("superMegaBigCss.css")
    .pipe(splitFiles())
    .pipe(gulp.dest("path/to/dest"));
});

This will produce three files:

  • superMegaBigCss-0.css
  • superMegaBigCss-1.css
  • superMegaBigCss-2.css

Name the new files

/*splitfilename=first.css*/
[lots of css stuff]
/*split*/
/*splitfilename=second.css*/
[lots more css stuff]

This will produce two files:

  • first.css
  • second.css
/*splitfilename=first.css*/
[lots of css stuff]
/*split*/
[lots more css stuff]
/*split*/
/*splitfilename=third.css*/
[even more css stuff]

This will produce three files:

  • first.css
  • superMegaBigCss-1.css
  • third.css

gulp-split-files's People

Contributors

markovchainmontecarlo avatar petterboozegunk avatar rathpc avatar

Forkers

rhincodon

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.