Socket
Socket
Sign inDemoInstall

gulp-readmin

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-readmin

Load files from script and link tags into a stream


Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

gulp-readmin

Load files from script and link tags into a stream to do with as you wish

Build status Dependency status

Usage

First, install gulp-readmin as a development dependency:

npm install --save-dev gulp-readmin

Then, add it to your gulpfile.js:

var readmin = require('gulp-readmin');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');

gulp.task('minifyjs', function () {
  return gulp.src('templates/layout.html')
      .pipe(readmin({type: 'js'))
      .pipe(uglify())
      .pipe(concat('scripts.min.js'))
      .pipe(gulp.dest('build'));
});

API

Blocks

Blocks are expressed as:

<!-- build:<pipelineId>(alternate search path) -->
... HTML Markup, list of script / link tags.
<!-- endbuild -->
  • pipelineId: js or css
  • alternate search path: (optional) By default the input files are relative to the treated file. Alternate search path allows one to change that

For example:

<!-- build:js -->
<script src="lib/framework.js"></script>
<script src="src/app.js"></script>
<!-- endbuild -->

Options

type

Type String

Set to js or css to filter out the other type. Default is to include both in stream.

path

Type: String

Default alternate search path for files. Can be overridden by the alternate search path option for a given block.

Use case

|
+- gulpfile.js
+- src
|   +- templates
|       +- layout.php
+- web
|   +- index.php
|   +- js
|   |   +- foo.js
|   |   +- bar.js
|   +- css
|   |   +- normalize.css
|   |   +- main.css
|   +- build

We want to optimize scripts (in the correct order) into scripts.min.js, and styles into styles.min.css. layout.php should contain the following blocks:

    <!-- build:css(web) -->
    <link rel="stylesheet" href="css/clear.css"/>
    <link rel="stylesheet" href="css/main.css"/>
    <!-- endbuild -->

    <!-- build:js(web) -->
    <script src="js/foo.js"></script>
    <script src="js/bar.js"></script>
    <!-- endbuild -->

We want our files to be generated in the web/build directory. gulpfile.js should contain the following tasks:

gulp.task('minifycss', function () {
  return gulp.src('src/templates/layout.php')
      .pipe(readmin({type:'css'}))
      .pipe(minifyCss())
      .pipe(concat('styles.min.css'))
      .pipe(gulp.dest('web/build'));
});

gulp.task('minifyjs', function () {
  return gulp.src('src/templates/layout.php')
      .pipe(readmin({type:'js'}))
      .pipe(uglify())
      .pipe(concat('scripts.min.js'))
      .pipe(gulp.dest('web/build'));
});

Changelog

0.1.2
  • pin gulp-usemin version
0.1.1
  • documentation
0.1.0
  • initial release

Keywords

FAQs

Package last updated on 09 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc