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

w-pages

v0.0.1

Published

gulp config package

Downloads

2

Readme

w-pages

gulp打包工具包

cli

# 清除打包产物
$ gulp clean

# 生产打包
$ gulp build

# 本地开发
$ gulp dev

过程

  1. 首先安装gulp和gulp-cli,使本地可使用gulp,并从gulp中解构出src读取流和dest写入流。
  2. 实现js类型文件的打包,引入gulp-babel、@babel/core、@babel/preset-env三个模块,封装script任务,实现js新特性编译为es5。
  3. 实现scss类型文件打包,引入gulp-sass模块,封装style任务,实现scss类型文件编译成css。
  4. 实现html类型文件按照模板进行渲染,并压缩打包,封装page任务,引入gulp-swig模块使用swig模板对html进行渲染同时注入变量。
  5. 实现图片和字体资源的打包,引入gulp-imagemin模块,分别封装image任务和font任务,通过gulp-imagemin模块对各种图片格式和svg格式的字体进行特殊打包处理,其他类型直接打包。
  6. 实现其他静态资源打包,封装extra任务直接进行打包。
  7. 实现本地启动服务,并进行实时热编译,引入browser-sync模块,封装serve任务,通过browser-sync任务在本地启动服务,并从gulp中解构出watch方法对js,css,html文件进行监听,实时监听这三类文件的变化并重新执行相应任务或重载页面实现热编译。
  8. 每次打包或者启动服务前先删除上一次打包的产物,引入del模块,封装clean任务,使用del模块清除掉指定目录下的打包文件。
  9. 实现将打包后的文件进行生产环境压缩,引入useref模块,封装useref方法,并引入gulp-uglify模块实现js文件的压缩,引入gulp-clean-css模块实现css类型文件的压缩,引入gulp-htmlmin模块对html类型文件进行压缩。
  10. (非必要)引入gulp-load-plugins模块,将所有gulp模块统一使用该模块导出引用,无需一一导出引用。
  11. 从gulp中解构出parallel(并行), series(串行)对之前封装的任务进行组合,组合成: - build:生产时打包需要用先串行执行clean,清除掉之前打包产物后,再并行执行script、style、page、image、font、extra任务到dist文件夹下,实现生产环境打包。 - compile:开发时编译js、css、html,并行执行script、style、page任务到.temp目录下实现开发环境临时编译, - dev: 本地开发时,先串行执行clean,清除掉之前打包产物后,先执行compile任务生成临时编译产物后再执行serve任务启动本地服务。

配置文件: pages.config.js

在项目根目录下创建pages.config.js作为配置文件,格式字段参考本项目根目录下的pages.config.js