我如何在我的gulp文件中添加构建任务? [英] How can i add a Build Task on my gulpfile?

查看:146
本文介绍了我如何在我的gulp文件中添加构建任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图安装一个名为BOSS的项目。



这是当我试图运行 bin / buildout -c frontend.cfg 时得到的结果。
您可以在这里查看整个安装步骤。

 < USER> @ubuntu:/ opt / boss $ sudo bin / buildout -c frontend.cfg 
安装frontend-admin。
npm WARN package.json boss-admin@1.0.0没有描述
npm WARN package.json boss-admin@1.0.0没有自述文件数据
npm WARN package.json angular-perfect- scrollbar@0.5.5没有存储库字段。
npm WARN package.json eslint-plugin-class-property@0.0.3无资料库字段。
npm http GET https://registry.npmjs.org/bower
npm http 304 https://registry.npmjs.org/bower
bower@1.7.9 node_modules / bower
npm WARN package.json boss-admin@1.0.0没有描述
npm WARN package.json boss-admin@1.0.0没有自述文件数据
npm WARN package.json angular-perfect-scrollbar @ 0.0.5没有存储库字段。
npm WARN package.json eslint-plugin-class-property@0.0.3无资料库字段。
npm http GET https://registry.npmjs.org/bower/1.5.2
npm http 304 https://registry.npmjs.org/bower/1.5.2
npm http GET https://registry.npmjs.org/abbrev
npm http GET https://registry.npmjs.org/archy/1.0.0
npm http GET https://registry.npmjs.org / bower-config
npm http GET https://registry.npmjs.org/bower-endpoint-parser
npm http GET https://registry.npmjs.org/bower-logger
npm http GET https://registry.npmjs.org/bower-json
npm http GET https://registry.npmjs.org/bower-registry-client
npm http GET https:// registry .npmjs.org / cardinal / 0.4.4
npm http GET https://registry.npmjs.org/chalk
npm http GET https://registry.npmjs.org/configstore
npm http GET https://registry.npmjs.org/decompress-zip
npm http GET https://registry.npmjs.org/chmodr/0.1.0
npm http GET https:// registry .npmjs.org / fstream
npm http GET https://registry.npmjs.org/fstream-ignore
npm http GET https://registry.npmjs.org/github
npm http GET ht tps://registry.npmjs.org/deep-sort-object
npm http GET https://registry.npmjs.org/glob
npm http GET https://registry.npmjs.org/ graceful-fs
npm http GET https://registry.npmjs.org/handlebars
npm http GET https://registry.npmjs.org/is-root
npm http GET https: //registry.npmjs.org/inquirer/0.8.0
npm http GET https://registry.npmjs.org/insight
npm http GET https://registry.npmjs.org/junk
npm http GET https://registry.npmjs.org/mout
npm http GET https://registry.npmjs.org/lockfile
npm http GET https://registry.npmjs。 org / lru-cache

----------- CUT ---- ----------

  npm http 304 https://registry.npmjs.org/amdefine 
npm http GET https://registry.npmjs.org/end-of-stream/1.0.0
npm http GET https://registry.npmjs.org/stream-shift
npm http GET https://registry.npmjs.org/es6-iterator
npm http GET https://registry.npmjs.org/es6-symbol
npm http 304 https://registry.npmjs.o rg / es6-symbol
npm http 304 https://registry.npmjs.org/es6-iterator
npm http 304 https://registry.npmjs.org/es6-iterator
npm http 304 https://registry.npmjs.org/es6-symbol
npm http 304 https://registry.npmjs.org/pinkie-promise
npm http 304 https://registry.npmjs。 org / stream-shift
npm http GET https://registry.npmjs.org/pinkie
npm http 304 https://registry.npmjs.org/end-of-stream/1.0.0
npm http GET https://registry.npmjs.org/once
npm http 304 https://registry.npmjs.org/pinkie
npm http 304 https://registry.npmjs。 org / once
bower@1.5.2 node_modules / bower
├──is-root@1.0.0
├──abbrev@1.0.9
├──垃圾@ 1.0.3
├──stringify-object@1.0.1
├──user-home@1.1.1
├──chmodr@0.1.0
├── opn@1.0.2
├──archy@1.0.0
├──bower-logger@0.2.2
├──bower-endpoint-parser@0.2.2
├──nopt@3.0.6
├──lru-cache@2.7.3
├──retry@0.6。 1
├──lockfile@1.0.2
├──tmp@0.0.24
├──q@1.4.1
├──semver@2.3.2
├──p-throttler@0.1.1(q@0.9.7)
├──which@1.2.11(isexe@1.1.2)
├──deep-sort- object@0.1.1(mout@0.9.1)
├──mout@0.11.1
├──graceful-fs@3.0.11(natives@1.1.0)
├ ──request-progress@0.3.1(throttleit@0.0.2)
├──shell-quote@1.6.1(array-filter@0.0.1,array-reduce@0.0.0,array-map @ 0.0.0,jsonify@0.0.0)
├──bower-json@0.4.0(intersect@0.0.3,deep-extend@0.2.11,graceful-fs@2.0.3)
├──mkdirp@0.5.0(minimist@0.0.8)
├──fstream@1.0.10(inherits@2.0.3,graceful-fs@4.1.6)
├─ ─github@0.2.4(mime@1.3.4)
├──chalk@1.1.3(escape-string-regexp@1.0.5,supports-color@2.0.0,ansi-styles@2.2。 1,has-ansi@2.0.0,strip-ansi@3.0.1)
├──promptly@0.2.0(read@1.0.7)
├──bower-config@0.6。 1(osenv@0.3.3,graceful-fs@2.0.3,mout@0.9.1,optimist@0.6.1)
├──cardinal@0.4.4(ansicolors@0.2.1,redeyed@0.4.4)
├──configstore@0.3.2(object-assign@2.1.1,xdg-basedir@1.0.1, uuid@2.0.3,osenv@0.1.3,js-yaml@3.6.1)
├──fstream-ignore@1.0.5(inherits@2.0.3,minimatch@3.0.3)
├──rimraf@2.5.4(glob@7.1.0)
├──glob@4.5.3(inherits@2.0.3,inflight@1.0.5,once@1.4.0,minimatch@2.0 .10)
├──insight@0.5.3(object-assign@2.1.1,async@0.9.2,tough-cookie@0.12.1,lodash.debounce@3.1.1,os-name @ 1.0.3)
├──request@2.53.0(tunnel-agent@0.4.3,caseless@0.9.0,forever-agent@0.5.2,aws-sign2@0.5.0,stringstream@0.0 .5,oauth-sign@0.6.0,isstream@0.1.2,json-stringify-safe@5.0.1,node-uuid@1.4.7,qs@2.3.3,form-data@0.2.0,强硬-cookie@2.3.1,bl@0.9.5,combined-stream@0.0.7,mime-types@2.0.14,http-signature@0.10.1,hawk@2.3.1)
├── decompress-zip@0.1.0(mkpath@0.1.0,touch@0.0.3,readable-stream@1.1.14,binary@0.3.0)
├──tar-fs@1.13.2(泵@ 1.0.1,tar-stream@1.5.2)
├──bower-registry-client@0.3.0(graceful-fs@2.0.3,request-replay@0.2.0,rimraf@2.2.8,lru-cache@2.3.1,async@0.2.10,mkdirp @ 0.3.5,request@2.51.0)
├──handlebars@2.0.0(optimist@0.3.7,uglify-js@2.3.6)
├──inquirer@0.8.0 (ansi-regex@1.1.1,mute-stream@0.0.4,through@2.3.8,figures@1.7.0,readline2@0.1.1,chalk@0.5.1,lodash@2.4.2,rx@2.5 .3,cli-color@0.3.3)
└──update-notifier@0.3.2(is-npm@1.0.0,semver-diff@2.1.0,string-length@1.0.1, latest-version@1.0.1)
[20:47:43]工作目录改为/ opt / boss / frontend / admin
[20:47:43]使用gulpfile / opt / boss / frontend /admin/gulpfile.js
[20:47:43]任务'build'不在你的gulpfile中
[20:47:43]请检查文档的正确gulpfile格式
While :
安装frontend-admin。

由于zc.buildout或
配方中的错误而发生内部错误:
Traceback(最近一次调用最后一次):
文件 /opt/boss/.buildout/eggs/zc.buildout-2.5.3-py3.4.egg/zc/buildout/buildout.py,第1995行,主
getattr(buildout,command)(args )
安装文件/opt/boss/.buildout/eggs/zc.buildout-2.5.3-py3.4.egg/zc/buildout/buildout.py,第666行
installed_files = self [part] ._ call(recipe.install)
文件/opt/boss/.buildout/eggs/zc.buildout-2.5.3-py3.4.egg/zc/buildout/buildout.py ,第1410行,在_call
返回f()
文件/opt/boss/eggs/collective.recipe.cmd-0.11-py3.4.egg/collective/recipe/cmd/__init__.py ,第56行,安装
self.execute()
文件/opt/boss/eggs/collective.recipe.cmd-0.11-py3.4.egg/collective/recipe/cmd/__init__ .py,第69行,执行
run_commands(cmds,self.shell)
文件/opt/boss/eggs/collective.recipe.cmd-0.11-py3.4.egg/collective/配方/ CMD / __中在run_commands
check_call('%s%s'%(shell,tmpfile),shell = True)
文件/usr/lib/python3.4/subprocess。 py,第561行,在check_call中
引发CalledProcessError(retcode,cmd)
subprocess.CalledProcessError:命令'sh / tmp / tmprbxr2129 / run'返回非零退出状态1

这就是我的 gulpfile.js 的样子。

  var gulp = require('gulp'),
extractTranslate = require('gulp-angular-translate-extractor');


gulp.task('i18n',function(){
var i18ndest ='./assets/translations';
return gulp.src([
'!../ shared / skyline / ** / *。tpl.html',
'!../ shared / skyline / ** / *。js',
'! ./shared/openstackService/**/*.js',
'../shared/**/*.tpl.html',
'../shared/**/*.js ',
'./src/**/*.tpl.html',
'./src/**/*.js',
'./lib/**/ * .tpl.html',
'./lib/**/*.js'
])
.pipe(extractTranslate({
defaultLang:'en.i18n' ,
lang:['en.i18n','ru.i18n'],
dest:i18ndest,
safeMode:false,//不要删除旧翻译
stringifyOptions: true //强制json被排序
}))
.pipe(gulp.dest(i18ndest));
});

这是一个用于前端/管理的构建手册

  cd< project-dir> /frontend/admin 
npm install
npm run install
npm run compile
最后一个命令创建带有编译和缩小的管理前端的'bin'文件夹。

npm运行开发
该命令将构建的代码放置在构建文件夹中,使用livereload启动本地Web服务器,观察者在文件更改时重建应用程序。

npm run i18n
该命令提取角度翻译的所有翻译键并将它们放到admin / src / assets / translations

npm run test
该命令运行karma测试

,这是前端/ lk的构建手册


$ b $

  cd< project-dir> /frontend/admin 
npm install
npm run install
npm run build
最后一条命令创建带有编译和缩小的管理前端的bin文件夹。

npm运行开发
该命令将构建的代码放置在构建文件夹中,使用livereload启动本地Web服务器,观察者在文件更改时重建应用程序。

npm run i18n
该命令提取角度翻译的所有翻译键并将它们放到admin / src / assets / translations

npm run test

该命令运行karma测试

如何解决 20:47:43]任务'build'不在你的gulpfile中错误?



需要你的帮助。谢谢。

解决方案

回答您的问题:当您运行 gulp x 时, gulpfile.js 必须包含

  gulp.task('x' ...); 

就你而言,你可以运行 gulp i18n ,它将运行名为 i18n 的任务,或者您可以将 i18n 任务重命名为 build然后运行 gulp build






<请注意,这里有很多事情要做。首先,它看起来像你还没有初始化你的package.json - 这是什么

  npm WARN package.json boss -admin@1.0.0没有描述
npm WARN package.json boss-admin@1.0.0没有自述文件数据
npm WARN package.json angular-perfect-scrollbar@0.0.5没有版本库字段。
npm WARN package.json eslint-plugin-class-property@0.0.3无资料库字段。

即将来临。运行

  npm初始

,它会引导您完成初始化(您将首先备份当前的 package.json )。



我建议您先从 https:// css-tricks .com / gulp-for-beginners /


I am trying to install a project named "BOSS".

This is what i got when i tried to run bin/buildout -c frontend.cfg. You can check the whole installation step on HERE.

<USER>@ubuntu:/opt/boss$ sudo bin/buildout -c frontend.cfg
Installing frontend-admin.
npm WARN package.json boss-admin@1.0.0 No description
npm WARN package.json boss-admin@1.0.0 No README data
npm WARN package.json angular-perfect-scrollbar@0.0.5 No repository field.
npm WARN package.json eslint-plugin-class-property@0.0.3 No repository field.
npm http GET https://registry.npmjs.org/bower
npm http 304 https://registry.npmjs.org/bower
bower@1.7.9 node_modules/bower
npm WARN package.json boss-admin@1.0.0 No description
npm WARN package.json boss-admin@1.0.0 No README data
npm WARN package.json angular-perfect-scrollbar@0.0.5 No repository field.
npm WARN package.json eslint-plugin-class-property@0.0.3 No repository field.
npm http GET https://registry.npmjs.org/bower/1.5.2
npm http 304 https://registry.npmjs.org/bower/1.5.2
npm http GET https://registry.npmjs.org/abbrev
npm http GET https://registry.npmjs.org/archy/1.0.0
npm http GET https://registry.npmjs.org/bower-config
npm http GET https://registry.npmjs.org/bower-endpoint-parser
npm http GET https://registry.npmjs.org/bower-logger
npm http GET https://registry.npmjs.org/bower-json
npm http GET https://registry.npmjs.org/bower-registry-client
npm http GET https://registry.npmjs.org/cardinal/0.4.4
npm http GET https://registry.npmjs.org/chalk
npm http GET https://registry.npmjs.org/configstore
npm http GET https://registry.npmjs.org/decompress-zip
npm http GET https://registry.npmjs.org/chmodr/0.1.0
npm http GET https://registry.npmjs.org/fstream
npm http GET https://registry.npmjs.org/fstream-ignore
npm http GET https://registry.npmjs.org/github
npm http GET https://registry.npmjs.org/deep-sort-object
npm http GET https://registry.npmjs.org/glob
npm http GET https://registry.npmjs.org/graceful-fs
npm http GET https://registry.npmjs.org/handlebars
npm http GET https://registry.npmjs.org/is-root
npm http GET https://registry.npmjs.org/inquirer/0.8.0
npm http GET https://registry.npmjs.org/insight
npm http GET https://registry.npmjs.org/junk
npm http GET https://registry.npmjs.org/mout
npm http GET https://registry.npmjs.org/lockfile
npm http GET https://registry.npmjs.org/lru-cache

----------- CUT --------------

npm http 304 https://registry.npmjs.org/amdefine
npm http GET https://registry.npmjs.org/end-of-stream/1.0.0
npm http GET https://registry.npmjs.org/stream-shift
npm http GET https://registry.npmjs.org/es6-iterator
npm http GET https://registry.npmjs.org/es6-symbol
npm http 304 https://registry.npmjs.org/es6-symbol
npm http 304 https://registry.npmjs.org/es6-iterator
npm http 304 https://registry.npmjs.org/es6-iterator
npm http 304 https://registry.npmjs.org/es6-symbol
npm http 304 https://registry.npmjs.org/pinkie-promise
npm http 304 https://registry.npmjs.org/stream-shift
npm http GET https://registry.npmjs.org/pinkie
npm http 304 https://registry.npmjs.org/end-of-stream/1.0.0
npm http GET https://registry.npmjs.org/once
npm http 304 https://registry.npmjs.org/pinkie
npm http 304 https://registry.npmjs.org/once
bower@1.5.2 node_modules/bower
├── is-root@1.0.0
├── abbrev@1.0.9
├── junk@1.0.3
├── stringify-object@1.0.1
├── user-home@1.1.1
├── chmodr@0.1.0
├── opn@1.0.2
├── archy@1.0.0
├── bower-logger@0.2.2
├── bower-endpoint-parser@0.2.2
├── nopt@3.0.6
├── lru-cache@2.7.3
├── retry@0.6.1
├── lockfile@1.0.2
├── tmp@0.0.24
├── q@1.4.1
├── semver@2.3.2
├── p-throttler@0.1.1 (q@0.9.7)
├── which@1.2.11 (isexe@1.1.2)
├── deep-sort-object@0.1.1 (mout@0.9.1)
├── mout@0.11.1
├── graceful-fs@3.0.11 (natives@1.1.0)
├── request-progress@0.3.1 (throttleit@0.0.2)
├── shell-quote@1.6.1 (array-filter@0.0.1, array-reduce@0.0.0, array-map@0.0.0, jsonify@0.0.0)
├── bower-json@0.4.0 (intersect@0.0.3, deep-extend@0.2.11, graceful-fs@2.0.3)
├── mkdirp@0.5.0 (minimist@0.0.8)
├── fstream@1.0.10 (inherits@2.0.3, graceful-fs@4.1.6)
├── github@0.2.4 (mime@1.3.4)
├── chalk@1.1.3 (escape-string-regexp@1.0.5, supports-color@2.0.0, ansi-styles@2.2.1, has-ansi@2.0.0, strip-ansi@3.0.1)
├── promptly@0.2.0 (read@1.0.7)
├── bower-config@0.6.1 (osenv@0.0.3, graceful-fs@2.0.3, mout@0.9.1, optimist@0.6.1)
├── cardinal@0.4.4 (ansicolors@0.2.1, redeyed@0.4.4)
├── configstore@0.3.2 (object-assign@2.1.1, xdg-basedir@1.0.1, uuid@2.0.3, osenv@0.1.3, js-yaml@3.6.1)
├── fstream-ignore@1.0.5 (inherits@2.0.3, minimatch@3.0.3)
├── rimraf@2.5.4 (glob@7.1.0)
├── glob@4.5.3 (inherits@2.0.3, inflight@1.0.5, once@1.4.0, minimatch@2.0.10)
├── insight@0.5.3 (object-assign@2.1.1, async@0.9.2, tough-cookie@0.12.1, lodash.debounce@3.1.1, os-name@1.0.3)
├── request@2.53.0 (tunnel-agent@0.4.3, caseless@0.9.0, forever-agent@0.5.2, aws-sign2@0.5.0, stringstream@0.0.5, oauth-sign@0.6.0, isstream@0.1.2, json-stringify-safe@5.0.1, node-uuid@1.4.7, qs@2.3.3, form-data@0.2.0, tough-cookie@2.3.1, bl@0.9.5, combined-stream@0.0.7, mime-types@2.0.14, http-signature@0.10.1, hawk@2.3.1)
├── decompress-zip@0.1.0 (mkpath@0.1.0, touch@0.0.3, readable-stream@1.1.14, binary@0.3.0)
├── tar-fs@1.13.2 (pump@1.0.1, tar-stream@1.5.2)
├── bower-registry-client@0.3.0 (graceful-fs@2.0.3, request-replay@0.2.0, rimraf@2.2.8, lru-cache@2.3.1, async@0.2.10, mkdirp@0.3.5, request@2.51.0)
├── handlebars@2.0.0 (optimist@0.3.7, uglify-js@2.3.6)
├── inquirer@0.8.0 (ansi-regex@1.1.1, mute-stream@0.0.4, through@2.3.8, figures@1.7.0, readline2@0.1.1, chalk@0.5.1, lodash@2.4.2, rx@2.5.3, cli-color@0.3.3)
└── update-notifier@0.3.2 (is-npm@1.0.0, semver-diff@2.1.0, string-length@1.0.1, latest-version@1.0.1)
[20:47:43] Working directory changed to /opt/boss/frontend/admin
[20:47:43] Using gulpfile /opt/boss/frontend/admin/gulpfile.js
[20:47:43] Task 'build' is not in your gulpfile
[20:47:43] Please check the documentation for proper gulpfile formatting
While:
  Installing frontend-admin.

An internal error occurred due to a bug in either zc.buildout or in a
recipe being used:
Traceback (most recent call last):
  File "/opt/boss/.buildout/eggs/zc.buildout-2.5.3-py3.4.egg/zc/buildout/buildout.py", line 1995, in main
    getattr(buildout, command)(args)
  File "/opt/boss/.buildout/eggs/zc.buildout-2.5.3-py3.4.egg/zc/buildout/buildout.py", line 666, in install
    installed_files = self[part]._call(recipe.install)
  File "/opt/boss/.buildout/eggs/zc.buildout-2.5.3-py3.4.egg/zc/buildout/buildout.py", line 1410, in _call
    return f()
  File "/opt/boss/eggs/collective.recipe.cmd-0.11-py3.4.egg/collective/recipe/cmd/__init__.py", line 56, in install
    self.execute()
  File "/opt/boss/eggs/collective.recipe.cmd-0.11-py3.4.egg/collective/recipe/cmd/__init__.py", line 69, in execute
    run_commands(cmds, self.shell)
  File "/opt/boss/eggs/collective.recipe.cmd-0.11-py3.4.egg/collective/recipe/cmd/__init__.py", line 39, in run_commands
    check_call('%s %s' % (shell, tmpfile), shell=True)
  File "/usr/lib/python3.4/subprocess.py", line 561, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'sh /tmp/tmprbxr2129/run' returned non-zero exit status 1

This is what my gulpfile.js looks like.

var gulp = require('gulp'),
  extractTranslate = require('gulp-angular-translate-extractor');


    gulp.task('i18n', function () {
      var i18ndest = './assets/translations';
      return gulp.src([
          '!../shared/skyline/**/*.tpl.html',
          '!../shared/skyline/**/*.js',
          '!../shared/openstackService/**/*.js',
          '../shared/**/*.tpl.html',
          '../shared/**/*.js',
          './src/**/*.tpl.html',
          './src/**/*.js',
          './lib/**/*.tpl.html',
          './lib/**/*.js'
        ])
        .pipe(extractTranslate({
          defaultLang: 'en.i18n',
          lang: ['en.i18n', 'ru.i18n'],
          dest: i18ndest,
          safeMode: false, // do not delete old translations
          stringifyOptions: true // force json to be sorted
        }))
        .pipe(gulp.dest(i18ndest));
    });
    ~                                 

This is a build manual for frontend/admin

cd <project-dir>/frontend/admin
    npm install
    npm run install
    npm run compile
    The last command creates 'bin' folder with compiled and minified admin frontend.

    npm run dev
    The command places built code inside a build folder, start local web server with livereload and watchers to rebuild app on files changes.

    npm run i18n
    The command extracts all translations keys for angular translate and place them to admin/src/assets/translations

    npm run test
    The command runs karma tests

and this is the build manual for frontend/lk

 cd <project-dir>/frontend/admin
    npm install
    npm run install
    npm run build
    The last command creates 'bin' folder with compiled and minified admin frontend.

    npm run dev
    The command places built code inside a build folder, start local web server with livereload and watchers to rebuild app on files changes.

    npm run i18n
    The command extracts all translations keys for angular translate and place them to admin/src/assets/translations

    npm run test

The command runs karma tests

How can i fix the [20:47:43] Task 'build' is not in your gulpfile Error?

Need your help. Thanks.

解决方案

To answer your question: when you run gulp x, your gulpfile.js has to include

gulp.task('x' ... );

In your case, you could run gulp i18n, which would run the task named i18n or you could rename the i18n task to build and then run gulp build.


Note there are a bunch of things going on here. To start with, it looks like you haven't initialized your package.json - that's what the

npm WARN package.json boss-admin@1.0.0 No description
npm WARN package.json boss-admin@1.0.0 No README data
npm WARN package.json angular-perfect-scrollbar@0.0.5 No repository field.
npm WARN package.json eslint-plugin-class-property@0.0.3 No repository field.

are coming from. Run

npm init

and it'll walk you through initialization (you'll want to back up your current package.json first).

I recommend you start by working through https://css-tricks.com/gulp-for-beginners/

这篇关于我如何在我的gulp文件中添加构建任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆