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

gulpfile-composer

v0.0.1

Published

A gulpfile compose tool that let you could write gulpfile seperately.

Downloads

2

Readme

gulpfile-composer

A gulpfile compose tool that let you could write gulpfile seperately.

⚠️ This is not a gulp plugin.

How to use

Prepare a workspace that using gulp build tool

Before you get started, verify the gulp version.

gulp --verson

The above command should out like the following:

[10:00:15] CLI version 2.0.1
[10:00:15] Local version 4.0.0

install

npm install --save-dev gulpfile-composer

Create gulp tasks in seperate files

This is just a demo, you could use any directory or file names as your needs.

  • make a gulp-tasks directory
  • place a css.dev.js to it
  • place a js.dev.js to it

Import all tasks into main gulpfile

  • modify the main gulpfile.js
const gulpfileComposer = require('gulpfile-composer')

// tasks directory
const tasksDir = './gulp-tasks'

// load all tasks in directory into tasks object
const tasks = gulpfileComposer.tasksFromDir(tasksDir)

// now you can add more features to tasks

// the main tasks exported
module.exports = tasks

Done

Run the following command, you should see the tasks list.

gulp --tasks

The limitation

  • It does not work when using ES6/Babel
  • It does not work when using TypeScript

To support these features, you can rewrite the code of this repo to fit it, and publish as a npm package to let the world better 😊

Why gulpfile-composer

When you work on a heavy repo, build tasks are heavy too.

The gulp website said:

Many users start by adding all logic to a gulpfile. If it ever grows too big, it can be refactored into separate files.

Each task can be split into its own file, then imported into your gulpfile for composition. Not only does this keep things organized, but it allows you to test each task independently or vary composition based on conditions.

Node's module resolution allows you to replace your gulpfile.js file with a directory named gulpfile.js that contains an index.js file which is treated as a gulpfile.js. This directory could then contain your individual modules for tasks.

It shows a derection, but how to do, it said nothing.

Who using gulpfile-composer

😂

Compare to other tools

How about mount-tasks?

It's outdated since I write the tool.

  • It use a old style gulp.task() API, but now it's recommand to use module.exports.
  • It's error message could not friendly 😢

How about requireDir?

It's outdated too.

  • It can be used in an old style gulp.task() API gulpfile, but cannot work by module.exports.

How does it work

It read a a directory that config gulpfiles, and exports all the files exports to a single object, you can attach that object to the main gulpfile.

More details please see the code.

Contribution

Feel free to help improve this project.

License

The MIT License.