我试图在Gulp中uglify Browserify的输出,但它不起作用.
gulpfile.js
var browserify = require('browserify');
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var source = require('vinyl-source-stream');
gulp.task('browserify', function() {
return browserify('./source/scripts/app.js')
.bundle()
.pipe(source('bundle.js'))
.pipe(uglify()) // ???
.pipe(gulp.dest('./build/scripts'));
});
Run Code Online (Sandbox Code Playgroud)
据我所知,我不能按照以下步骤进行.我是否需要在一个管道中制作以保留序列?
gulp.task('browserify', function() {
return browserify('./source/scripts/app.js')
.bundle()
.pipe(source('bundle.js'))
.pipe(uglify()) // ???
.pipe(gulp.dest('./source/scripts'));
});
gulp.task('scripts', function() {
return grunt.src('./source/scripts/budle.js')
.pipe(uglify())
.pipe(gulp.dest('./build/scripts'));
});
gulp.task('default', function(){
gulp.start('browserify', 'scripts');
});
Run Code Online (Sandbox Code Playgroud) 如果我想将ascii符号形式js添加到某个节点?尝试作为一个TextNode
,但它没有解析它作为代码:
var dropdownTriggerText = document.createTextNode('blabla ∧');
Run Code Online (Sandbox Code Playgroud) 情况:几个开发人员在SPA的不同部分/模块上远程工作.因此,他们可能会意外地引入相同的HTML元素id
.在最终组合之前,有哪些常见方法可以避免这种情况(如果可能的话,不拒绝使用id)?
我的浅见猜测:
预先安排id
所有的名字(有点荒谬,但......)
具有架构的结构名称,例如用于app/collection/model
专用的名称app-collection-model
id
一般拒绝使用s或仅用于大型模块?
此外,变量可以传递给匿名包装器来本地化常用的全局变量,例如window,document和jQuery ......
var module = (function (window, document, $) {
// module stuff
})(window, document, jQuery);
Run Code Online (Sandbox Code Playgroud)
如果这些本地化可以全球访问,那么本地化的重点是什么?
为什么聚合
aggregate.near({
near: coord,
distanceField: "distance",
maxDistance: max
});
Run Code Online (Sandbox Code Playgroud)
可以回来
{
"name": "MongoError",
"errmsg": "exception: geoNear command failed: { ok: 0.0, errmsg: \"more than one 2d index, not sure which to run geoNear on\" }",
"code": 16604,
"ok": 0
}
Run Code Online (Sandbox Code Playgroud)
在该计划中唯一的2d指数:
location: { type: [ Number ], index: '2d', sparse: true },
Run Code Online (Sandbox Code Playgroud)
或多或少当我从方案中删除所有错误时,错误会改变原因吗?为什么......
它似乎很简单但不起作用:
<html ng-app>
<head>
<script type="text/javascript" src="lib/angular.js"></script>
<script type="text/javascript">
function HelloController($scope) {
$scope.greeting = { text: 'Hello' };
}
</script>
</head>
<body>
<div ng-controller='HelloController'>
<p>{{greeting.text}}, World</p>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
在屏幕上:
{{greeting.text}}, World
Run Code Online (Sandbox Code Playgroud)
并在控制台中:
Error: [ng:areq] Argument 'HelloController' is not a function, got undefined
http://errors.angularjs.org/1.3.0/ng/areq?p0=HelloController&p1=not%20a%20function%2C%20got%20undefined
at http://localhost:8080/lib/angular.js:80:12
at assertArg (http://localhost:8080/lib/angular.js:1610:11)
at assertArgFn (http://localhost:8080/lib/angular.js:1620:3)
at http://localhost:8080/lib/angular.js:8319:9
at http://localhost:8080/lib/angular.js:7496:34
at forEach (http://localhost:8080/lib/angular.js:343:20)
at nodeLinkFn (http://localhost:8080/lib/angular.js:7483:11)
at compositeLinkFn (http://localhost:8080/lib/angular.js:6991:13)
at compositeLinkFn (http://localhost:8080/lib/angular.js:6994:13)
at compositeLinkFn (http://localhost:8080/lib/angular.js:6994:13)
Run Code Online (Sandbox Code Playgroud)
看不出为什么......除了因为我使用AngularJS v1.3.0
?
javascript ×6
node.js ×2
angularjs ×1
browserify ×1
gulp ×1
mongodb ×1
mongoose ×1
naming ×1
uglifyjs ×1