
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
gulp-ng-html2js
Advanced tools
A Gulp plugin which generates AngularJS modules, which pre-load your HTML code into the $templateCache. This way AngularJS doesn't need to request the actual HTML files anymore.
A plugin for gulp which generates AngularJS modules, which pre-load your HTML code into the $templateCache. This way AngularJS doesn't need to request the actual HTML files anymore.
First, install gulp-ng-html2js
as a development dependency:
npm install --save-dev gulp-ng-html2js
Then, add it to your gulpfile.js
:
var ngHtml2Js = require("gulp-ng-html2js");
gulp.src("./partials/*.html")
.pipe(ngHtml2Js({
moduleName: "MyAwesomePartials",
prefix: "/partials"
}))
.pipe(gulp.dest("./dist/partials"));
The main reason to use this module would be optimization. By pre-loading the HTML files, you can spare requests and
loading time when the files are actually needed. When you are optimizing, you should do it properly. So, we should add
the following plugins: gulp-minify-html
, gulp-uglify
, and gulp-concat
:
var ngHtml2Js = require("gulp-ng-html2js");
var minifyHtml = require("gulp-minify-html");
var concat = require("gulp-concat");
var uglify = require("gulp-uglify");
gulp.src("./partials/*.html")
.pipe(minifyHtml({
empty: true,
spare: true,
quotes: true
}))
.pipe(ngHtml2Js({
moduleName: "MyAwesomePartials",
prefix: "/partials"
}))
.pipe(concat("partials.min.js"))
.pipe(uglify())
.pipe(gulp.dest("./dist/partials"));
This way you end up with 1 single, minified Javascript file, which pre-loads all the (minified) HTML templates.
Type: String
The name of the generated AngularJS module. Uses the file url if omitted.
Type: String
The prefix which should be prepended to the file path to generate the file url.
Type: String
The prefix which should be subtracted from the file path to generate the file url.
FAQs
A Gulp plugin which generates AngularJS modules, which pre-load your HTML code into the $templateCache. This way AngularJS doesn't need to request the actual HTML files anymore.
The npm package gulp-ng-html2js receives a total of 3,556 weekly downloads. As such, gulp-ng-html2js popularity was classified as popular.
We found that gulp-ng-html2js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.