{"id":41527170,"url":"https://github.com/webcoding/gulp-tasks","last_synced_at":"2026-01-23T22:21:56.080Z","repository":{"id":57259199,"uuid":"44094200","full_name":"webcoding/gulp-tasks","owner":"webcoding","description":"gulp-tasks-build","archived":false,"fork":false,"pushed_at":"2016-01-12T07:08:59.000Z","size":39,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-26T02:25:24.239Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webcoding.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-12T08:27:58.000Z","updated_at":"2023-05-19T06:54:59.000Z","dependencies_parsed_at":"2022-08-25T04:50:22.005Z","dependency_job_id":null,"html_url":"https://github.com/webcoding/gulp-tasks","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/webcoding/gulp-tasks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webcoding%2Fgulp-tasks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webcoding%2Fgulp-tasks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webcoding%2Fgulp-tasks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webcoding%2Fgulp-tasks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webcoding","download_url":"https://codeload.github.com/webcoding/gulp-tasks/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webcoding%2Fgulp-tasks/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28701560,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T17:25:48.045Z","status":"ssl_error","status_checked_at":"2026-01-23T17:25:47.153Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-23T22:21:55.020Z","updated_at":"2026-01-23T22:21:56.074Z","avatar_url":"https://github.com/webcoding.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gulp-tasks\n\n收集开发常用的 tasks 任务列表，汇总成 [gulp-tasks-build](https://www.npmjs.com/package/gulp-tasks-build)。\n\n基于 amazeui-gulp-tasks 的结构，综合常用的 tasks 任务列表汇总而成，让 Coding 更 Happy ！。\n\n## 问题\n\n痛苦的安装，每一个项目引用，都要 install 这个东东，并且编译依赖，好慢啊，而且明显的有点浪费，本来只需要安装一次就行了啊。\n应该提供一种方式，比如我安装到全局，但在项目中可以引用，这样就方便了。\n\n所以要使用一种能自动 require('全局模块') 的方式给项目引用，我最先想到的是在想使用的地方，使用npm link到local。\n\n```\n//这个配置待定下，上次使用的配置，忘记了，改天再整理下\n#在项目开发目录，使用软链接 ln –s 源文件 目标文件(这个效果不好，貌似缺了某些依赖，运行不起来)\nln -s /usr/local/lib/node_modules/require-global ./node_modules/require-global\nln -s /usr/local/lib/node_modules/gulp ./node_modules/gulp\nln -s /usr/local/lib/node_modules/run-sequence ./node_modules/run-sequence\nln -s /usr/local/lib/node_modules/gulp-tasks-build ./node_modules/gulp-tasks-build\n\n//我是要开发修改的，不安装全局了（sass 每次编译好慢）\nln -s ~/github/webcoding/gulp-tasks ./node_modules/gulp-tasks-build\n\n### 我想到可以install 一个模块去加载全局的模块，于是发现了 require-global\nnpm install -g require-global\n\n\nbrowser-sync browserify browserify-shim del derequire gulp gulp-autoprefixer gulp-cache gulp-concat gulp-csso gulp-eslint gulp-gh-pages gulp-git gulp-header gulp-if gulp-imagemin gulp-less gulp-load-plugins gulp-md5-plus gulp-minify-html gulp-nodemon gulp-plumber gulp-rename gulp-replace gulp-sftp gulp-shell gulp-size gulp-sourcemaps gulp-stylus gulp-uglify gulp-util gulp-zip lodash markit-json object-assign require-dir run-sequence vinyl-buffer vinyl-source-stream watchify\n```\n\n如果不用显式的运行，如果全局安装有，自动去查询加载就好了。\n\n在网上也发现已经有这样的[需求](http://segmentfault.com/q/1010000000396247)，weakish 回答可以尝试使用\n[autod](https://github.com/node-modules/autod)，这个是什么鬼，通过项目文件引用自动生成依赖，貌似不合适。\n\n### Task list\n\n```\ngulp clean  //洗刷刷，重新来！\ngulp copy   //copy 项目依赖文件到编译目录，如字体，外部依赖的 css/js\ngulp html   //copy 项目 html 到编译目录\n\ngulp styles //编译样式，根据配置类型，可编译 less sass 或 stylus\ngulp browserify //编译 JS，编译 CommonJS 格式的模块\n            styles 和 browserify，在开发环境通过 map 调试，生成环境其引用会追加版本号\ngulp server //开发预览服务器\n            开发环境使用：gulp dev\n            生产使用：NODE_ENV=production gulp\n```\n\n### TODO list\n\n使用 webpack 形式组织及打包文件?\n\n这里不集成了，因为 webpack 打包的独立性，独自汇总一个使用示例项目，参见 webpack-tools\n\n```\nrename.js  //重命名脚本，可集成编译或copy 的任务流中，完成指定重命名\nreplace.js //自定义替换脚本，可集成编译或copy 的任务流中，完成指定内容的替换\ngulp uglify  //压缩/丑化 task，待定（编译处已处理）\ngulp jshint //JS 格式校验（暂未使用）\ngulp images  //对样式中图片进行处理（暂未使用）\n               gulp-imagemin + imagemin-pngquant 或 gulp-tinypng 形式\ngulp publish //发布项目\ngulp upload  //上传文件到远程 FTP 服务器\ngulp zip     //打包 build 后的项目\ngulp markdown //编译 markdown 文件，生成文档\ngulp help    //输出此 gulp-tasks 的帮助\n```\n\n### 本项目测试及效果体验\n\n```\n下载安装\ngit clone https://github.com/webcoding/gulp-tasks.git\nnpm install\nbower install   //引入的外界依赖，如 normalize.css pure.css react 等\n\n运行\ngulp dev 或者 NODE_ENV=production gulp\n```\n\n## 安装及使用\n\n```\n$ npm install gulp-tasks-build --save-dev\n```\n\n在 `gulpfile.js` 中调用任务：\n\n```js\n// gulpfile.js\n\n'use strict';\n\nvar gulp = require('gulp');\nvar tasks = require('gulp-tasks-build');\nvar runSequence = require('run-sequence');\n\n// 项目配置\nvar projectConfig = {\n  projectName: 'tests',   //项目名称，可用于打 zip 包\n  srcRoot: 'tests',       //项目源目录\n  distRoot: 'dist'        //编译输出目录\n};\n\n// Task配置\nvar config = {\n  projectName: projectConfig.projectName,\n  srcRoot: projectConfig.srcRoot,\n  distRoot: projectConfig.distRoot,\n\n  styles: {\n    type: 'sass', //编译类型 less sass 或 stylus\n    src: projectConfig.srcRoot + '/scss/style.scss', //也可以是数组\n    autoPrefixer: [],  //autoPrefixer 配置，如果为空，则按项目内部默认值设定\n    dist: projectConfig.distRoot + '/css',\n    watches: projectConfig.srcRoot + '/**/*.scss',\n    banner: false\n  },\n};\n\ntasks(gulp, config);\n\ngulp.task('build', function(cb) {\n  //根据你的需求，选择需要的 tasks 任务，别忘了配置\n  runSequence('clean', ['html', 'browserify', 'styles'], cb);\n});\n\n// 不要直接使用 gulp.task('dev', ['build', 'server']);\n// build 和 server 没有先后执行顺序，可能时序错乱，建议如下使用\ngulp.task('dev', function(cb) {\n  runSequence('build', 'server', cb);\n});\n```\n\n### autoPrefixer 默认配置\n\n```\nvar autoPrefixer = [\n  'ie \u003e= 9',\n  'ie_mob \u003e= 10',\n  'ff \u003e= 30',\n  'chrome \u003e= 34',\n  'safari \u003e= 7',\n  'opera \u003e= 23',\n  'ios \u003e= 7',\n  'android \u003e= 2.3',\n  'bb \u003e= 10'\n];\n```\n\n## 任务及配置说明\n\n### `styles`\n\n编译 styles。配置如下：\n\n```js\nvar config = {\n  styles: {\n    type: 'less', // 编译类型 less sass 或 stylus（gulp-sass 安装编译超级慢）\n    src: './tests/less/test.less', // 源文件\n    autoPrefixer: {}, // autoprefixer 设置，\n    dist: './dist/css', // 部署目录\n    watches: '', // watch 的文件，如果不设置则 watch `src` 里的文件\n    banner: false // 是否添加 banner，布尔值或者 {template: '', data: {}}\n  }\n}\n```\n\n### `browserify`\n\n使用 Browserify 打包 JS。\n\n```js\nvar isProduction = process.env.NODE_ENV === \"production\";\nvar config = {\n  browserify: {\n    bundleOptions: {\n      entries: './tests/js/app.js',\n      debug: !isProduction\n      cache: {},\n      packageCache: {}\n    },\n    filename: 'app.js',\n    transforms: [\n      ['browserify-shim', {global: true}]\n    ],\n    plugins: [],\n    dist: 'dist/js',\n    banner: false\n  },\n}\n```\n\n### `uglify`\n\n```js\nvar config = {\n  uglify: {\n    src: './tasks/*.js',\n    dist: './dist',\n    banner: false\n  }\n}\n```\n\n### `markdown` 还未启用\n\n```js\nvar config = {\n  md: {\n    src: ['README.md'],\n    data: {\n      pluginTitle: 'Gulp Tasks for happyCoding',\n      pluginDesc: 'gulp-tasks-build 让 Coding 更 Happy！！！'\n    },\n    // gulp-rename 设置\n    rename: function(file) {\n      file.basename = file.basename.toLowerCase();\n      if (file.basename === 'readme') {\n        file.basename = 'index';\n      }\n      file.extname = '.html';\n    },\n    dist: function(file) {\n      if (file.relative === 'index.html') {\n        return 'dist'\n      }\n      return 'dist/docs';\n    }\n  },\n}\n```\n\n### `clean`\n\n清理任务：\n\n```js\nvar config = {\n  clean: '' // 要清理的文件夹\n};\n```\n\n### `server`\n\n开发预览服务器：编译开发预览、编译生产代码、发布到生产\n\n```\ngulp dev\nNODE_ENV=production gulp build\ngulp publish\n```\n\n### `release` 还未启用\n\n发布任务：\n\n- `publish:tag` - 添加 `tag` 并 push 到远程 git 仓库\n- `publish:npm` - 发布到 NPM\n- `publish:docs` - Push 文档到 GitHub `gh-pages` 分支\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebcoding%2Fgulp-tasks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebcoding%2Fgulp-tasks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebcoding%2Fgulp-tasks/lists"}