我不明白如何正确工作鲍尔

我正在build立一个网站,我已经决定使用引导模板的后端(pipe理工具和whatnot)。

我喜欢sb-admin-2( http://startbootstrap.com/template-overviews/sb-admin-2/ )的外观,但我有点困惑如何在我的网站实际使用这个。 我安装了Bower并使用bower install startbootstrap-sb-admin-2

现在我有一个名为bower_components的文件夹,并且它包含了所有相关的软件包…但是,这些软件包也包含了开发文件。

如果我上传到我的网站,80%是不必要的源数据。 我目前正在使用Gulp与我的项目,但我还没有看到2应该如何互动。 是否有一个编译bower_components成为一个简洁的东西gulp包?

我是新来的这种工作stream程,尽pipe我努力了,但是我找不到答案。 道歉,如果我听起来像一个总noob。

没有预先build立的一揽子包,将拉入所有的鲍尔源文件。 你应该写一个任务,只提取你需要的文件。 以下是我正在进行的项目(简化)的一个示例:

 var scripts = [ 'bower_components/timezone-js/src/date.js', // https://github.com/mde/timezone-js 'bower_components/jquery/jquery.min.js', // http://api.jquery.com/ 'bower_components/jquery-migrate/jquery-migrate.js', // https://github.com/appleboy/jquery-migrate 'bower_components/jquery-ui/ui/minified/jquery-ui.min.js', // todo: include just the bits we need 'bower_components/jqueryui-touch-punch/jquery.ui.touch-punch.min.js', // https://github.com/furf/jquery-ui-touch-punch 'bower_components/jquery-cookie/jquery.cookie.js', // https://github.com/carhartl/jquery-cookie 'bower_components/jquery.expander/jquery.expander.min.js', // https://github.com/kswedberg/jquery-expander 'bower_components/jquery.transit/jquery.transit.js', // http://ricostacruz.com/jquery.transit/ 'bower_components/select2/select2.min.js', // http://ivaynberg.github.io/select2/ 'bower_components/fancybox/source/jquery.fancybox.pack.js', // http://fancyapps.com/fancybox/ 'bower_components/lodash/dist/lodash.compat.min.js', // https://lodash.com/docs 'bower_components/underscore.string/dist/underscore.string.min.js', // https://github.com/epeli/underscore.string#string-functions 'bower_components/json2/json2.js', // https://github.com/douglascrockford/JSON-js 'bower_components/jquery-validation/dist/jquery.validate.min.js', // http://jqueryvalidation.org/documentation/ 'bower_components/jquery-file-upload/js/jquery.iframe-transport.js', 'bower_components/jquery-file-upload/js/jquery.fileupload.js', // https://blueimp.github.io/jQuery-File-Upload/ 'bower_components/DataTables/media/js/jquery.dataTables.js', // https://datatables.net/ ]; gulp.task('scripts', function () { return gulp.src(scripts, {base: '.'}) .pipe(plumber()) .pipe(sourcemaps.init({ loadMaps: false, debug: debug, })) .pipe(concat('all_the_things.js', { newLine:'\n;' // the newline is needed in case the file ends with a line comment, the semi-colon is needed if the last statement wasn't terminated })) .pipe(uglify({ output: { // http://lisperator.net/uglifyjs/codegen beautify: debug, comments: debug ? true : /^!|\b(copyright|license)\b|@(preserve|license|cc_on)\b/i, }, compress: { // http://lisperator.net/uglifyjs/compress, http://davidwalsh.name/compress-uglify sequences: !debug, booleans: !debug, conditionals: !debug, hoist_funs: false, hoist_vars: debug, warnings: debug, }, mangle: !debug, outSourceMap: true, basePath: 'www', sourceRoot: '/' })) .pipe(sourcemaps.write('.', { includeContent: true, sourceRoot: '/', })) .pipe(plumber.stop()) .pipe(gulp.dest('www/js')) }); 

我正在挑选我想要的源文件,将它们合并和缩小,然后将它们转储到我的公共目录中,以便将其提供给客户端。 您不需要将bower_components文件夹上传到生产服务器; 但它可能也不会伤害太多(这不是很大!)。