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

thinbuilder

v2.3.0

Published

A scripts builder middleware for thinjs

Downloads

19

Readme

thinbuilder

基于 Express 的 THINJS 构建中间件,用来动态打包 THINJS 编写的脚本文件。

npm version

如何安装

npm install thinbuilder

如何使用

Express 引用示例

打开 app.js 文件,按照如下方式添加代码引用:

......
const thinbuilder = require("thinbuilder");
......
app.use(express.static(path.join(__dirname, "public")));
app.use(thinbuilder());
......

自定义配置

我们提供了两种方式调整 thinbuilder 编译属性:参数配置和文件配置,其中文件配置优先级最高。

  1. 参数配置

    app.js 中添加如下配置参数:

    app.use(thinbuilder({alias:"thinbuilder",debug:true [,...params]}));
  2. 文件配置(推荐)

    项目根目录下创建 thin.config.json文件,配置示例如下:

    {
    	"alias": "thinbuilder",
    	"priority": [{ "path": "test", "files": ["y.js", "subfolder/s.js"] }],
    	"mode": "folder",
    	"debug": true,
    	"minify": true,
    	"cachetime": 600
    }
  3. 配置参数说明

    • alias:定义 thinjs 根目录名称,用来存放 thinjs 脚本文件,默认值为 thinbuilder。

      注意:文件夹必须放置在项目根目录,早期含有 jsbuilder 文件夹的项目可以省略该参数。

      {
      	"alias": "thinbuilder"
      }
    • minify:启用脚本混淆/压缩开关,未配置时将会根据环境变量设定初始值(production 为 true,其他为 false)。

      {
      	"minify": true
      }
    • terserOpts:混淆/压缩选项配置,仅当 minify 为 true 时有效,默认配置为:

      {
      	"format": { "comments": false },
      	"compress": {
      		"drop_console": ["log", "info"],
      		"drop_debugger": true,
      		"sequences": false
      	},
      	"mangle": true
      }
    • cachetime:设置客户端缓存时间(秒),默认不缓存。

      {
      	"cachetime": 600
      }
    • debug:调试日志开关,开启后控制台打印编译过程日志信息,未配置时将会根据环境变量设定初始值(production 为 false,其他为 true)。

      {
      	"debug": true
      }
    • mode:扫描模式,用来告诉编译器优先解析打包对象(folder|file),默认为 folder。

      {
      	"mode": "folder"
      }
    • priority:设置 thinjs 文件构建顺序(数组格式),默认构建顺序为文件名排序,该属性可以灵活调整 thinjs 文件构建顺序。

      1. path属性设置需要调整的文件夹路径
      2. files属性设置需要优先构建的文件路径,支持子目录文件。

      注意:不建议“/”开头、字母大小写敏感。

      {
      	"priority": [
      		{
      			"path": "test",
      			"files": ["file2.js", "subfolder/file1.js"]
      		}
      	]
      }

其他说明

  1. 我们推荐在项目根目录下使用 thinbuilder 作为 thinjs 根文件夹,当然早期的 jsbuilder 文件夹一样兼容。
  2. Node Version >= 15.0.0。
  3. 支持压缩/混淆功能。