如何使用gulp连接JS库文件? [英] How to concat JS library files using gulp?

查看:173
本文介绍了如何使用gulp连接JS库文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请查看我的要点:$ b​​ $ b https://gist.github.com/flyspaceage / 9e88716294df93c8eaece51fe413f7a3



除JS库之外,我的所有文件似乎都能正确连接。我使用JS Socials,JS Scrollify,Headroom,JQuery 2.1.1,JS Slick。这些文件可以连接成一个缩小文件,但这些库不再适用于生产。我正在编写我的第一个Gulp文件,任何关于Gulp的建议都非常感谢。

解决方案

将供应商库放在不同的位置。之所以不工作,是因为您正在清理源文件存在的dist目录。



将目录中存在的所有脚本移动到文件夹'vendor'

  libs:['dist / scripts / libs / jquery.headroom.js','dist / scripts / libs / headroom。 js','dist / scripts / libs / jssocials.js','dist / scripts / libs / slick.min.js','dist / scripts / libs / jquery.scrollify.js'],

然后将文件夹路径更改为供应商

  libs:['vendor / scripts / libs / jquery.headroom.js','vendor / scripts / libs / headroom.js',etc .. ,,,,],


Please check out my gist: https://gist.github.com/flyspaceage/9e88716294df93c8eaece51fe413f7a3

All of my files seem to concat properly except the JS libraries. Im using JS Socials, JS Scrollify, Headroom, JQuery 2.1.1, JS Slick. The files concat into one minified file, but the libraries no longer work in production. I am writing my first Gulpfile, any suggestions focused on Gulp appreciated.

解决方案

Place your vendor libraries in a different location. The reason why its not working is you are cleaning the dist directory, where the source files are present.

Move all the scripts present in this directory to a folder 'vendor'

libs: ['dist/scripts/libs/jquery.headroom.js', 'dist/scripts/libs/headroom.js', 'dist/scripts/libs/jssocials.js', 'dist/scripts/libs/slick.min.js', 'dist/scripts/libs/jquery.scrollify.js'],

then change the folder path to vendor

libs: ['vendor/scripts/libs/jquery.headroom.js', 'vendor/scripts/libs/headroom.js', etc..,,,],

这篇关于如何使用gulp连接JS库文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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