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

@xysfe/rollup-plugin-auto-html

v0.0.4

Published

Rollup plugin to auto inject script into html file

Downloads

1

Readme

rollup-plugin-auto-html

下载

npm i @xysfe/rollup-plugin-auto-html -D

使用方式

rollup.config.js

import html from '@xysfe/rollup-plugin-auto-html'

const configMap = {
  'app': {
    prefix: 'public/h5/',
    htmlName: 'appjs',
    templatePath: '',
  },
  'tongji': {
    prefix: '',
    templatePath: ''
  },
  'gb750': {
    prefix: 'public/h5/'
  }
}

const config = [
  {
    plugins: [
      html({ configMap, env: process.env.NODE_ENV })
    ]
  }
]

注意事项

  1. 插件强依赖于NODE_ENV环境变量,用于处理线上发布后会导致测试环境资源不可访问的现状,若没有该变量则会退出构建。正式环境的NODE_ENV必须是production,否则无法构建出正确的资源路径。

    NODE_ENV环境变量注入方式:

    // file: package.json
    "scripts": {
      "dev": "cross-env NODE_ENV=development npm run bundle",
      "dist": "cross-env NODE_ENV=production npm run bundle"
    }
  2. 如果不传入configMap配置项,插件将不会生成html文件,该配置项的每一个key值,都对应着一个html文件

功能

该插件会生成html文件,并将打包后的文件以标签的形式引入html文件,效果如下:

示例图片1

示例图片2

配置项

| Name | Type | Default | Description | | ---- | ---- | ---- | ---- | | configMap | {Object} | {} | 生成html文件的配置 | | env | {String} | undefined | 环境变量 |

注意:configMap配置项的key值,应为文件入口名。

configMap配置选项

| Name | Type | Default | Description | | ---- | ---- | ---- | ---- | | prefix | {String} | '' | 生成html文件的目录前缀 | | htmlName | {String} | '' | 生成html文件的文件名 | | templatePath | {String} | '' | 模板文件的路径,会在标签前插入模板文件的内容 |