npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rollup-plugin-gen-html

v0.2.7

Published

rollup plugin for generating html file from template & injecting bundled files

Downloads

23

Readme

rollup-plugin-gen-html

generate html file & inject bundled files

Installation

npm install rollup-plugin-gen-html -D

or

yarn add rollup-plugin-gen-html --dev

Usage

Minimal

it can be zero config to bundle with .vue files.

rollup.config.js :

import html from 'rollup-plugin-gen-html' // this plugin
import postcss from 'rollup-plugin-postcss' // handle .pcss files

export default {
    input: 'src/index.js',
    output: {
        file: 'dist/app.js'
    },
    plugins: [
        html(),
        postcss({ /* postcss plugin options */ })
    ]
}

src/index.js :

import './index.html'  // import as template
import './css/index.pcss' // 

src/index.html

<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Example</title>
  </head>
  <body>
    <div id="app"></div>
    <script type="text/javascript" src="./lib/vue/vue.runtime.js"></script>
  </body>
</html>
output :

dist/index.html

<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Example</title>
    <link rel="stylesheet" type="text/css" href="app.css">
  </head>
  <body>
    <div id="app"></div>
    <script type="text/javascript" src="./lib/vue/vue.runtime.min.js"></script>
    <script type="text/javascript" src="app.js"></script>
  </body>
</html>

options

include
  • type: string
  • default: **/*.html

files that will be handled

exclude
  • type: string
  • default: undefined

files that will be ignored

template
  • type: string
  • default: undefined

Specify a html file, and load the content as template.

If there are html files that import within scripts, this option will be ignored.

in some cases, you need to specify a template by environment variable or arguments, use this option.

output
  • type: string
  • default: undefined

output path of the html file(s),related to cwd.

If has a single html file, it can be a file path, otherwise it should be a directory.

hash
  • type: string | boolean
  • default: false

Put a md5 value of the bundle file, or use the specify string value, as part of the bundle filenames.

Then, the output html file looks like:

dist/index.html

<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Example</title>
    <link rel="stylesheet" type="text/css" href="app.2234a93729a0e7115216f9a5d55f93c4.css">
  </head>
  <body>
    <div id="app"></div>
    <script type="text/javascript" src="./lib/vue/vue.runtime.min.js"></script>
    <script type="text/javascript" src="app.b572d3ac186ca60072b05e7892848a73.js"></script>
  </body>
</html>
replaceToMinScripts
  • type: boolean
  • default: true

Auto replace script src to *.min.js , if exist.

insertCssRef
  • type: boolean
  • default: true

Insert css file ref into html content, if exist.