标签: factor-bundle

如何在同一个browserify命令中缩小和分解文件?

我目前有这个factor-bundle命令,我用它来捆绑我的文件,并将所有常见的东西拉到一个公共文件中:

browserify index.js bar-charts.js list-filter.js dashboard.js 
  -p [ factor-bundle -o ../../static/js/index.js -o ../../static/js/bar-chart.js -o ../../static/js/list-filter.js -o ../../static/js/dashboard.js ] 
  -o ../../static/js/common.js
Run Code Online (Sandbox Code Playgroud)

我以前也使用此命令来uglify单个文件:

 browserify index.js | uglifyjs > ../../static/js/index.min.js
Run Code Online (Sandbox Code Playgroud)

如何在同一个命令中将文件与文件组合在一起factor-bundle并将其缩小uglifyjs

在因子包文档中找到了这个例子,但我真的不明白如何适应它.

(如果效果更好,我也可以使用两个命令.我只想最终得到缩小和组合的文件!)

javascript uglifyjs browserify factor-bundle

13
推荐指数
1
解决办法
471
查看次数

因子捆绑包裹时,Bootstrap不起作用?

我一直在使用factor-bundle来包装我的常见JS文件:

browserify index.js bar-charts.js list-filter.js dashboard.js 
 -p [ factor-bundle -o ../../static/js/index.js -o ../../static/js/bar-chart.js -o ../../static/js/list-filter.js -o ../../static/js/dashboard.js ] 
 -o ../../static/js/common.js
Run Code Online (Sandbox Code Playgroud)

然后我在我的HTML中包含了common.js以及一个Bootstrap警报:

 <div class="alert alert-danger alert-dismissible" role="alert">
    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
    Alert alert!
 </div> 
 <script src="/static/js/common.js"></script>
Run Code Online (Sandbox Code Playgroud)

但警报关闭按钮不起作用,因此Bootstrap显然没有被提取.

如果我在CDN中包含Bootstrap和jQuery,在同一个HTML页面中,它可以正常工作:

<div class="alert alert-danger alert-dismissible" role="alert">
    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
    Alert alert!
 </div> 
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
Run Code Online (Sandbox Code Playgroud)

这是一个JSFiddle与我的common.js文件,不工作:http://jsfiddle.net/2v9easbz/

这是一个JSFiddle与直接CDN链接,工作正常:http://jsfiddle.net/vkf027z2/

我的common.js文件有什么问题?

javascript twitter-bootstrap browserify factor-bundle

10
推荐指数
1
解决办法
171
查看次数

对factor-bundle的部分包进行一些操作

我正在使用浏览器和factor-bundle.我有以下代码:

b = browserify({
        entries: [ 'a.js', 'b.js'],
        plugin: [ [ 'factor-bundle', { outputs: [ 'build/a.js', 'build/b.js' ] } ] ]
    })
    .bundle()
    .pipe(source('bundle.js'))
    .pipe(buffer())
    .pipe(gulp.dest('/build/common'));
Run Code Online (Sandbox Code Playgroud)

我想在parial包('build/a.js'和'build/b.js')上管理一些动作(比如uglify,bundle-collapser或其他工作).我尝试使用factor-bundle页面上描述的方法:

b.plugin('factor-bundle', { outputs: [ write('x'), write('y') ] });
function write (name) {
    return concat(function (body) {
        console.log('// ----- ' + name + ' -----');
        console.log(body.toString('utf8'));
    });
}
Run Code Online (Sandbox Code Playgroud)

但我不理解write()方法,也不知道如何执行uglification以及如何gulp.dest结果.
任何的想法?说明?

javascript node.js browserify gulp factor-bundle

9
推荐指数
1
解决办法
978
查看次数