JSPM

pull-create-html

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q16945F

Create an html file from js and css file streams

Package Exports

  • pull-create-html

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pull-create-html) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

pull-create-html

Create an html file from js and css file streams

var pull = require('pull-stream')
var { read, write } = require('pull-files')
var bundle = require('pull-bundle-js')
var html = require('pull-create-html')

pull(
  html('app.html', {
    title: '',
    description: 'My website'
    // Others...
  
    js: pull(
      read(__dirname + '/lib/index.js'),
      bundle([ ...transforms ])
    ),

    css: pull(
      read(__dirname + '/style/index.sass'),
      sass()
    )
  }),
  write(__dirname + '/out', err => {
    // Finished
  })
)

Install

npm i pull-create-html

Usage

html(path?, options)

Creates an html file from js and css file streams, with several options configure the boilerplate html

  • js a stream of js files which put in <script>
  • css a stream of css files which get put in <style>
  • lang sets the <html lang=...> attribute. Defaults to en-US
  • title sets the <title>...</title> element
  • body is a string of HTML to put before where the JS is injected. e.g. a mount element for vdom
  • charset sets the <meta charset=...> element. Defaults to utf-8
  • description sets the <meta name='description'> element
  • keywords sets the <meta name='keywords'> element
  • base sets the file.base on the output HTML file
  • scriptAsync lets the JS files load async by setting <script async="true"> in the <head>

Files in the js/css stream are concatenated together. Allows streaming a directory of plain css files, for example.

Also see pull-pair for linking separate js/css pipelines:

var js = pair()
var css = pair()

pull(
  read(__dirname + '/lib/index.js'),
  bundle([ ...transforms ]),
  minify(),
  js.sink
)

pull(
  read(__dirname + '/style/**/*.sass'),
  sass(),
  minify(),
  css.sink
)

pull(
  // Create html from the js and css streams
  html('foo.html', { title: 'foo', js, css  }),
  write(__dirname + '/out', err => {
    // Finished
  })
)

Also see


Maintained by Jamen Marz (See on Twitter and GitHub for questions & updates)