我有应用程序代码结构,其中js文件分布在多个文件夹中.我们可以创建grunt uglify任务,以便将缩小的文件放在与src相同的文件夹中,或者将它放在/ dist下与src相同的文件夹下,这将以递归方式扫描应用程序中的所有src js文件.
在html中,我们必须包含所有js文件,但是希望保持正常的js用于开发和调试目的,并在测试和部署时缩小.它有更好的选择,所以我不必每次都更改main.html.
uglify: {
options: {
report: 'min',
mangle: false
},
controllers: {
files: {
'src/main/webapp/app/controllers/dist/controllers.min.js': ['src/main/webapp/app/controllers/*.js', '!src/main/webapp/app/controllers/dist/*.js']
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是uglify任务,但我希望它以递归方式查看src/main/webapp/app/for*.js文件中的所有文件夹和子文件夹,并在同一位置创建*.min.js.
如何在量角器硒中进行单次测试.
describe('Login page', function() {
beforeEach(function() {
browser.ignoreSynchronization = true;
ptor = protractor.getInstance();
});
it('should contain navigation items', function(){
//test case code here
});
it('should login the user successfully', function(){
//test case code here
})
});
Run Code Online (Sandbox Code Playgroud)
我想只运行一次测试.我可以使用它来运行它,fit但我想从命令行执行它而不更改测试.
另外我如何使用Grunt进行单独测试?
我只是想用汇编来运行一个快速的例子.我按照说明操作安装程序,输出就在这里
npm install assemble --save-dev
npm WARN package.json ocscommerce-frontend@0.1.0 No description
npm WARN package.json ocscommerce-frontend@0.1.0 No repository field.
npm WARN package.json ocscommerce-frontend@0.1.0 No README data
npm WARN package.json ocscommerce-frontend@0.1.0 No license field.
npm WARN engine get-stdin@5.0.1: wanted: {"node":">=0.12.0"} (current: {"node":"0.10.32","npm":"2.14.2"})
|
> fsevents@1.0.6 install /Users/Documents/Projects/OCSCommerce/prototype/web/themes/default/build/node_modules/assemble/node_modules/assemble-core/node_modules/base-tasks/node_modules/composer/node_modules/chokidar/node_modules/fsevents
> node-pre-gyp install --fallback-to-build
[fsevents] Success: "/Users/Documents/Projects/OCSCommerce/prototype/web/themes/default/build/node_modules/assemble/node_modules/assemble-core/node_modules/base-tasks/node_modules/composer/node_modules/chokidar/node_modules/fsevents/lib/binding/Release/node-v11-darwin-x64/fse.node" is installed via remote
assemble@0.7.0 node_modules/assemble
??? success-symbol@0.1.0
??? try-open@0.1.0
??? time-stamp@0.1.3
??? word-wrap@1.1.0
??? lazy-cache@1.0.3
??? base-cli@0.4.0
??? minimist@1.2.0
??? isobject@2.0.0 (isarray@0.0.1)
??? opn@3.0.3 (object-assign@4.0.1)
??? common-middleware@0.2.2 …Run Code Online (Sandbox Code Playgroud) [root @ iZ25q0v42mrZ myapps] #grunt server运行"服务器"任务
该
server任务已被弃用.使用grunt serve启动服务器.
运行"服务:未定义"(服务)任务
运行"clean:server"(干净)任务
清理1条路径.
运行"wiredep:app"(wiredep)任务
运行"wiredep:test"(wiredep)任务
运行"并发:服务器"(并发)任务
Running "copy:styles" (copy) task
Copied 1 file
Done, without errors.
Execution Time (2016-01-23 17:20:04 UTC)
loading tasks 236ms ??????????????????????????????? 88%
loading grunt-contrib-copy 18ms ??? 7%
copy:styles 13ms ?? 5%
Total 267ms
Run Code Online (Sandbox Code Playgroud)
运行"postcss:server"(postcss)任务
已创建1个已处理样式表.
运行"connect:livereload"(连接)任务已开始在http:// localhost:9090上连接Web服务器 致命错误:spawn EACCES
执行时间(2016-01-23 17:20:03 UTC)加载任务221ms▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇16%wiredep:app 163ms▇▇▇▇▇▇ ▇▇▇▇▇▇▇▇▇12%wiredep:测试16ms▇▇1%并发:服务器582ms▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇43%加载grunt-postcss54ms▇▇▇▇▇4%postcss:服务器148ms▇▇▇▇▇▇▇ ▇▇▇▇▇▇▇11%加载grunt-contrib-connect104ms▇▇▇▇▇▇▇▇▇▇8%连接:livereload28ms▇▇▇2%总计1.3s
谁能帮助我看看.谢谢
我在自定义的grunt任务中遇到了错误.下面我发布了一个与问题相关的简单测试用例:
Gruntfile.js
module.exports = function( grunt ){
grunt.task.registerTask( 'endsWith', 'Test of string.prototype.endsWith', function(){
var value = grunt.option('value');
grunt.log.writeln( typeof value );
grunt.log.writeln( value.endsWith( 'bar' ) );
})
};
Run Code Online (Sandbox Code Playgroud)
测试
> grunt endsWith --value=foobar
Running "endsWith" task
string
Warning: Object foobar has no method 'endsWith' Use --force to continue.
Aborted due to warnings.
Execution Time (2016-02-12 16:15:19 UTC)
Total 12ms
Run Code Online (Sandbox Code Playgroud)
就像grunt无法识别String.proptotype.endsWith函数一样.这是正常的吗?
编辑:我正在使用节点v0.10.4
我试图从节点运行我的摩卡测试.最终目标是通过istanbul/blanket添加代码覆盖,并生成一个lcov文件,用于输入声纳以进行代码覆盖.
这是一个示例项目,我正在尝试 https://github.com/rajarshigoswami/Todos
摩卡测试在 https://github.com/rajarshigoswami/Todos/tree/master/test/mocha下
测试是从浏览器运行的,但是当我通过节点尝试时,它不会接收任何spec文件.
使用方法:运行:npm install then:grunt
我的问题是:
我正在尝试使用react构建一个应用程序,但它不起作用,我无法理解为什么.所有东西都使用babelify进行编译,但它在性能期间会抛出异常.错误如下:未捕获的ReferenceError:未定义React.
这是我的组件文件(BigCard.jsx):
export var BigCard = React.createClass({
render: function() {
var rows = [];
for (var variable in this.props.pokemon) {
if (this.props.pokemon.hasOwnProperty(variable) && variable.toString() !== 'id' && variable.toString !== 'name' && variable.toString !== 'image' && variable.toString !== 'types') {
rows.push(
<tr>
<td class='mdl-data-table__cell--non-numeric'>
{variable}
</td>
<td>
{this.props.pokemon[variable]}
</td>
</tr>
)
}
}
return (
<div class='mdl-card mdl-shadow--4dp'>
<div class='mdl-card__title'>
<img src={this.props.pokemon.image.src} alt='Pokemon' class='bigCard__img'/>
</div>
<h2 class='mdl-card__title-text'></h2>
<div class='mdl-card__supporting-text'>
<table class='mdl-data-table mdl-js-data-table'>
<thead>
<tr>
<th class='mdl-data-table__cell--non-numeric'>Type</th>
<th class='mdl-data-table__cell--non-numeric'>{this.props.pokemon.types}</th>
</tr>
</thead>
<tbody> …Run Code Online (Sandbox Code Playgroud) 我试图用grunt-babel将我的es6编译成es5.当我进入grunt babel命令行时,它会挂起并且永远不会运行babel.它不会返回错误或崩溃它只是挂起.我在Gruntfile.js中有其他任务,它们运行得很好,因此Gruntfile.js的结构是正确的.
这是我的Gruntfile:
'use strict';
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
// initialize Grunt
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
'babel': {
options: {
sourceMap: true,
presets: ['babel-preset-es2015']
},
dist: {
files: {
'js/survey.js': 'build/survey.js'
}
}
},
// create jshint task
jshint: {
dev: {
// tell jshint what check
src: ['Gruntfile.js', 'server.js', 'js/**/*.js', 'models/**/*.js', 'routes/**/*.js', '!build/**', '!tests/client/bundle.js', '!tests/karma_tests/bundle.js', '!js/imageMapResizer.min.js', '!js/kickstart.js', '!js/form-validator.js', '!js/imageMapResizer.js', '!js/jquery-ui.min.js', '!js/jquery.base64.js', '!js/kickstart.js'],
options: {
node: true,
globals: {
describe: true,
it: true,
before: true,
after: true,
beforeEach: …Run Code Online (Sandbox Code Playgroud)我正在使用Grunt通过手表将我的SASS文件转换为CSS.
问题是:我可以正常运行Compass任务,CSS创建得非常好,但是当我使用WATCH时,我得到了错误:
grunt.util ._.contains不是函数
这是我的package.json:
{
"name": "myName",
"description": "myDesc",
"author": "mySelf",
"version": "0.0.1",
"private": true,
"devDependencies": {
"grunt": "^1.0.1",
"grunt-contrib-compass": "^1.1.1",
"grunt-contrib-jshint": "^0.10.0",
"grunt-contrib-nodeunit": "~0.4.1",
"grunt-contrib-sass": "^1.0.0",
"grunt-contrib-uglify": "^0.5.1",
"grunt-contrib-watch": "^0.4.4"
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的Gruntfile.js:
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
compass: {
dist: {
options: {
config: 'config.rb'
}
}
},
watch: {
css: {
files: 'assets/**/*.{scss,sass}',
tasks: ['compass']
}
}
});
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default',['compass','watch']);
};
Run Code Online (Sandbox Code Playgroud)
我尝试了很多改变,但没有任何帮助
更新!
经过漫长的一夜,解决问题 ......请阅读我自己的答案
我是image: ruby:2.3.1从gitlab CI使用的.需要部署以下包.
此外,如何确保每个构建gitlab不应该重新下载这些包(我的意思是重新使用它)
gruntjs ×10
javascript ×5
assemble ×1
babeljs ×1
bower ×1
browserify ×1
compass ×1
contains ×1
ecmascript-6 ×1
gitlab ×1
gitlab-ci ×1
grunt-babel ×1
istanbul ×1
mocha.js ×1
npm ×1
protractor ×1
reactjs ×1
requirejs ×1
task ×1
watch ×1
yeoman ×1