brfs-htmlmin
Advanced tools
Comparing version 1.1.0 to 2.0.0
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
var html = "<!DOCTYPE html>\r\n<html lang=\"en\">\r\n<head>\r\n <title>A RMScreenprint</title>\r\n</head>\r\n<body>\r\n <h1>Main heading in my document</h1>\r\n <!-- Note that it is \"h\" + \"1\", not \"h\" + the letters \"one\" -->\r\n <p>Look Ma, I am coding <abbr title=\"Hyper Text Markup Language\">HTML</abbr>.</p>\r\n</body>\r\n</html>"; | ||
var html = "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <title>A RMScreenprint</title>\n</head>\n<body>\n <h1>Main heading in my document</h1>\n <!-- Note that it is \"h\" + \"1\", not \"h\" + the letters \"one\" -->\n <p>Look Ma, I am coding <abbr title=\"Hyper Text Markup Language\">HTML</abbr>.</p>\n</body>\n</html>"; | ||
console.log(html); | ||
},{}]},{},[1]); |
38
index.js
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
var staticModule = require('static-module'); | ||
@@ -7,2 +8,3 @@ var quote = require('quote-stream'); | ||
var minify = require('html-minifier').minify; | ||
var defaults = require('lodash.defaults'); | ||
@@ -20,3 +22,4 @@ var regexps = [ | ||
opts = opts || {}; | ||
opts.minify = opts.minify || { | ||
var optsMinify = defaults(opts.minify || {}, { | ||
removeComments: true, | ||
@@ -28,8 +31,8 @@ collapseWhitespace: true, | ||
removeEmptyAttributes: true | ||
}; | ||
}); | ||
Object.keys(opts.minify).forEach(function (key) { | ||
Object.keys(optsMinify).forEach(function(key) { | ||
if(~regexps.indexOf(key)) { | ||
var value = opts.minify[key]; | ||
opts.minify[key] = Array.isArray(value) ? | ||
var value = optsMinify[key]; | ||
optsMinify[key] = Array.isArray(value) ? | ||
value.map(asRegExp) : | ||
@@ -44,6 +47,9 @@ asRegExp(value); | ||
}; | ||
if(opts.vars) Object.keys(opts.vars).forEach(function (key) { | ||
vars[key] = opts.vars[key]; | ||
}); | ||
if(opts.vars) { | ||
Object.keys(opts.vars).forEach(function(key) { | ||
vars[key] = opts.vars[key]; | ||
}); | ||
} | ||
var sm = staticModule( | ||
@@ -60,18 +66,18 @@ { | ||
function readFileSync(file, enc) { | ||
enc = enc || 'utf8'; | ||
function readFileSync(fileRead, encoding) { | ||
encoding = encoding || 'utf8'; | ||
var bufArr = []; | ||
return fs.createReadStream(file, { encoding: enc }) | ||
return fs.createReadStream(fileRead, { encoding: encoding }) | ||
.pipe(through(write, end)) | ||
.pipe(quote()); | ||
function write (buf, enc, next) { | ||
function write(buf, enc, next) { | ||
bufArr.push(buf); | ||
next(); | ||
} | ||
function end (next) { | ||
if(/\.html$/.test(file)) { | ||
this.push(minify(bufArr.toString('utf8'), opts.minify)); | ||
function end(next) { | ||
if(/\.html$/.test(fileRead)) { | ||
this.push(minify(bufArr.toString('utf8'), optsMinify)); | ||
} | ||
@@ -82,3 +88,3 @@ else { | ||
this.push(null); | ||
sm.emit('file', file); | ||
sm.emit('file', fileRead); | ||
next(); | ||
@@ -85,0 +91,0 @@ } |
{ | ||
"name": "brfs-htmlmin", | ||
"version": "1.1.0", | ||
"version": "2.0.0", | ||
"description": "browserify fs.readFileSync() static html file inliner with html minifier", | ||
@@ -30,2 +30,3 @@ "main": "index.js", | ||
"html-minifier": "^0.7.2", | ||
"lodash.defaults": "^3.1.2", | ||
"quote-stream": "0.0.0", | ||
@@ -32,0 +33,0 @@ "static-module": "^1.0.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8433
10
91
5
+ Addedlodash.defaults@^3.1.2
+ Addedlodash._baseassign@3.2.0(transitive)
+ Addedlodash._basecopy@3.0.1(transitive)
+ Addedlodash._bindcallback@3.0.1(transitive)
+ Addedlodash._createassigner@3.1.1(transitive)
+ Addedlodash._getnative@3.9.1(transitive)
+ Addedlodash._isiterateecall@3.0.9(transitive)
+ Addedlodash.assign@3.2.0(transitive)
+ Addedlodash.defaults@3.1.2(transitive)
+ Addedlodash.isarguments@3.1.0(transitive)
+ Addedlodash.isarray@3.0.4(transitive)
+ Addedlodash.keys@3.1.2(transitive)
+ Addedlodash.restparam@3.6.1(transitive)