grj

gulp-resolve-jsref

Used to import js files using grammar: '<link rel = "import" href = "filepath">'. It supports mult-level imports and automatically adjust the script reference path to be relative to the containing html file.

Showing:

Popularity

Downloads/wk

5

Maintenance

No Maintenance Data Available

Package

Dependencies

2

Size (min+gzip)

22.1KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

gulp-resolve-jsref Build Status Coverage Status

[NPM]

Please use 'gulp-resolve-import' instead. This plugin is no longer maintained.

Used to import js files using grammar: '<link rel = \"import\" href = \"filepath\">'. It supports mult-level imports and automatically adjust the script reference path to be relative to the containing html file.

Usage

  1. Declare imports in your file

/a.html

  <link rel = "import" href = "sub/b.jsref.html">

/sub/b.jsref.html

  <script type = "text/javascript" src="../../js/a.js"></script>
  <script type = "text/javascript">alert("Hello");</script>
  <script type = "text/javascript" src="../../js/b.js"></script>

  <link rel = "import" href = "sub2/c.jsref.html">

/sub/sub2/c.jsref.html

  <script type = "text/javascript" src="c.js"></script>
  <script type = "text/javascript">alert("World");</script>
  1. Specify the action in the build script.
  var gulp = require("gulp"),
      resolveJsRef = require("gulp-resolve-jsref");
    
  gulp.src("*.html").pipe(resolveJsRef());

The resulting html for a.html will be like:

  <script type = "text/javascript" src="../js/a.js"></script>
  <script type = "text/javascript">alert("Hello");</script>
  <script type = "text/javascript" src="../js/b.js"></script>

  <script type = "text/javascript" src="sub/sub2/c.js"></script>
  <script type = "text/javascript">alert("World");</script>

License

MIT

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100