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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@agds/gulp-config-preset

v1.0.4

Published

构建npm包的gulp配置

Downloads

16

Readme

@agds/gulp-config-preset

版本 :1.0.4

构建npm包的gulp配置

快速开始

安装

npm i -D @agds/gulp-config-preset

引入

// gulpfile.js
const gulpPreset = require('@agds/gulp-config-preset');
exports.default = gulpPreset();

添加build脚本

package.jsonscripts下添加build命令;

{
  "scripts": {
    "build": "gulp",
    "prepublishOnly": "npm run build"
  }
}

API文档

gulppreset(options) ⇒ Undertaker.TaskFunction

性质: 函数

| 参数 | 类型 | 描述 | | --- | --- | --- | | options | object | gulp出入口配置 | | options.input | string | gulp构建入口 | | options.output | string | gulp构建出口 |

gulppreset~clean() ⇒ Promise

清除构建目录

性质: gulppreset的内部方法

gulppreset~build() ⇒ merge.Merge2Stream

构建

性质: gulppreset的内部方法

gulppreset~cp() ⇒ NodeJS.ReadWriteStream

复制无法构建的文件

性质: gulppreset的内部方法

配置源码

const { series, src, dest, parallel } = require('gulp');
const rimraf = require('rimraf');
const babel = require('gulp-babel');
const ts = require('gulp-typescript');
const merge = require('merge2');
const { FastPath, FastFs } = require('@agds/node-utils');
const path = require('path');
/**
 * @param {object} options gulp出入口配置
 * @param {string} options.input gulp构建入口
 * @param {string} options.output gulp构建出口
 * @returns {Undertaker.TaskFunction}
 */
function gulppreset({ input = 'src', output = 'lib' } = {}) {
    let params = require('@agds/ts-config-js').compilerOptions;
    if (FastFs.getPathStatSync(FastPath.getCwdPath('tsconfig.json'))) {
        params = 'tsconfig.json';
    }
    const tsProject = ts.createProject(params);
    const _input = FastPath.getCwdPath(input);
    const _output = FastPath.getCwdPath(output);
    /**
     * 清除构建目录
     *
     * @returns {Promise}
     */
    function clean() {
        return new Promise((resolve) => rimraf(_output, resolve));
    };
    /**
     * 构建
     *
     * @returns {merge.Merge2Stream}
     */
    function build() {
        const tsResult = src(path.join(_input, '**/*.[tj]s'))
            .pipe(tsProject());

        return merge([
            tsResult.dts.pipe(dest(path.join(_output, 'types'))),
            tsResult.js.pipe(babel()).pipe(dest(_output)),
        ]);
    }

    /**
     * 复制无法构建的文件
     *
     * @returns {NodeJS.ReadWriteStream}
     */
    function cp() {
        return src(path.join(_input, '**/*.!([tj]s)')).pipe(dest(_output));
    }
    return series(clean, parallel(build, cp));
}

module.exports = gulppreset;

许可证

MIT License Copyright (c) 2021 锦阳

请维护者喝杯咖啡

加入钉钉群讨论或加入开发