Skip to content

vovanre/gulp-include-source-ex

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gulp-include-source-ex

Gulp plugin to include scripts and styles into your HTML files automatically.

Based on gulp-include-source fork by Xlander11

Install

Install with npm

npm install gulp-include-source-ex --save-dev

Example

gulpfile.js

const includeSources = require('gulp-include-source-ex');

return gulp.src('./client/index.html').pipe(includeSource({
		'cwd': 'src/',
		'prefix': 'js',
		'context': {
			'js_list': ['example/app.js', 'controllers/*.js']
		}
	})).pipe(gulp.dest('build/'));

index.html

<html>
<head>
  <!-- include:css(style/**/*.css) -->
</head>
<body>
  <!-- include:js(file:vendorListFile) -->
  <!-- include:js(list:js_list) -->
  <!-- include:js(script/**/*.js) -->
</body>
</html>

vendorListFile

/jquery/dist/jquery.js
/angular/angular.js

Result:

<html>
<head>
  <link rel="stylesheet" href="style/main.css">
</head>
<body>
  <script src="js/jquery/dist/jquery.js"></script>
  <script src="js/angular/angular.js"></script>
  <script src="js/example/app.js"></script>
  <script src="js/controllers/LoginController.js"></script>
  <script src="js/controllers/MainController.js"></script>
</body>
</html>

API

includeSources(options)

options.cwd

Type: String

Base directory from where the plugin will search for source files.

options.scriptExt

Type: String

When available, will override script extension in resulted HTML code.

options.styleExt

Type: String

When available, will override style extension in resulted HTML code.

options.prefix

Type: String

When available, will add before all filenames.

options.skipEmptyFiles

Type: boolean

When available, will skip all empty files

options.useHash

Type: boolean

When available, will add file hash to end filename /script.js?123456.

License

MIT © vovanre just.vovanre@gmail.com

About

Include scripts and styles into your HTML files automatically.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • JavaScript 100.0%