Security News
npm Updates Search Experience with New Objective Sorting Options
npm has a revamped search experience with new, more transparent sorting options—Relevance, Downloads, Dependents, and Publish Date.
gulp-seed基于gulp开发,是天猫前端通用的构建插件,它的主要功能是:
$ npm install -g gulp #安装gulp cli
ps:unix环境可能需要sudo权限
$ npm install --save-dev gulp
$ npm install --save-dev gulp-seed
在项目根目录下创建gulpfile.js,编写构建脚本,例如:
var path = require('path');
var gulp = require('gulp');
var code = require('gulp-seed');
//引入包配置
var pkg = require('./package.json');
//注册css构建任务
gulp.task('css', function () {
return gulp.src('src/**/*.css')
.pipe(code.lint()) //css代码检查
.pipe(code.minify()) //css代码压缩
.pipe(gulp.dest('build/'))
});
//注册js构建任务
gulp.task('js', function () {
return gulp.src('src/**/*.js')
.pipe(code.lint()) //js代码检查
.pipe(code.dep({
name: pkg.name,
path: 'http://g.tbcdn.cn/tm/' + pkg.name + '/' + pkg.version + '/',
exports:["*"]
}))
.pipe(code.minify()) //js代码压缩
.pipe(gulp.dest('build/'))
});
//注册一个默认任务
gulp.task('default', ['css', 'js']);
在项目根目录下执行
$ gulp
这样就完成了你的前端js和css文件的代码检查、依赖提取和代码压缩过程。
name
{String} 包名path
{String} 包路径replacePathInJSWithVar
{String} 用来变量名来替换seed.js中的host,例如g_config.assetsServer
version
{String} 包版本group
{String} KISSY combo分组,默认是tm
feDependencies
{Object} 前端模块(femodule)依赖useRequireAsync
{Boolean} 是否生成异步依赖到requires_async,默认为falsekissyConfig
{Object} KISSY.config配置项ignore
{Array} 依赖解析时忽略的模式,可选值有:KISSY14
、KISSY5
和CJS
useCache
: {Boolean} 生成seed自动merge上一次seed生成的结果,默认为falseuseMuiCache
: {Boolean} 缓存feDependencies生成的seed,默认为falseconcurent
: {Number} 拉取mui seed文件并发数timeInterval
: {Number} 拉取mui seed批次间隙wrapAMDWhenNoExports
: {Boolean} 是否在无module.exports时包裹define,默认为trueexports
: {Array} 要对外暴露的文件路径列表, 默认是["*"]
, 例如['src/index.js']
useFeDepSeedOnly
: {Boolean} 只对配置了的依赖进行seed合并及增加依赖信息useDemandDepSeed
: {Boolean} 只生成按需使用的seed内容ignoreRequires
: {Array} 需要ignore的rquire,将不会出现在 module.requires 中** 如果gulp watch 报错 请先关闭 gulp-cache,具体机制在考虑优化中 **
一个组件对外暴露的文件如果单独引用的价值才有暴露的意义
有时我们的代码会分拆成多个功能文件,但最终只需提供一个index文件对外使用
这时最合理的处理方式将index文件依赖的文件统一打包成一个文件(如xtemplate只需暴露runtime)
功能描述:
例子
|- src
|- fn1.js
|- fn2.js
|- util.js
fn1 require fn2,fn2 require util,此时我们只想暴露fn1,fn2
exports配置为["src/fn1.js","src/fn2.js"]
打包完成后对应的暴露的文件只有fn1.js,fn2.js
seed信息为(util已被合并到fn2.js,seed中不再有对应依赖):
{
fn1:{
requires:["fn2"]
}
}
最佳实践:
更多gulp使用手册请参考Gulp.js官方文档。
$ npm run build # build the source code with babel
$ npm run dev # build automatically when files change
$ npm run test # run unit tests
The MIT License (MIT)
Copyright (c) 2015 tmallfe
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
The npm package gulp-seed receives a total of 15 weekly downloads. As such, gulp-seed popularity was classified as not popular.
We found that gulp-seed demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm has a revamped search experience with new, more transparent sorting options—Relevance, Downloads, Dependents, and Publish Date.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.