<tfoot id='WREtF'></tfoot>

    1. <i id='WREtF'><tr id='WREtF'><dt id='WREtF'><q id='WREtF'><span id='WREtF'><b id='WREtF'><form id='WREtF'><ins id='WREtF'></ins><ul id='WREtF'></ul><sub id='WREtF'></sub></form><legend id='WREtF'></legend><bdo id='WREtF'><pre id='WREtF'><center id='WREtF'></center></pre></bdo></b><th id='WREtF'></th></span></q></dt></tr></i><div id='WREtF'><tfoot id='WREtF'></tfoot><dl id='WREtF'><fieldset id='WREtF'></fieldset></dl></div>

    2. <legend id='WREtF'><style id='WREtF'><dir id='WREtF'><q id='WREtF'></q></dir></style></legend>

      <small id='WREtF'></small><noframes id='WREtF'>

        <bdo id='WREtF'></bdo><ul id='WREtF'></ul>

      使用 Gulp 按顺序连接脚本

      时间:2023-05-28
            <bdo id='QFYnF'></bdo><ul id='QFYnF'></ul>

              <tbody id='QFYnF'></tbody>

          • <legend id='QFYnF'><style id='QFYnF'><dir id='QFYnF'><q id='QFYnF'></q></dir></style></legend>

              • <tfoot id='QFYnF'></tfoot>

                <small id='QFYnF'></small><noframes id='QFYnF'>

              • <i id='QFYnF'><tr id='QFYnF'><dt id='QFYnF'><q id='QFYnF'><span id='QFYnF'><b id='QFYnF'><form id='QFYnF'><ins id='QFYnF'></ins><ul id='QFYnF'></ul><sub id='QFYnF'></sub></form><legend id='QFYnF'></legend><bdo id='QFYnF'><pre id='QFYnF'><center id='QFYnF'></center></pre></bdo></b><th id='QFYnF'></th></span></q></dt></tr></i><div id='QFYnF'><tfoot id='QFYnF'></tfoot><dl id='QFYnF'><fieldset id='QFYnF'></fieldset></dl></div>
                本文介绍了使用 Gulp 按顺序连接脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                例如,您正在 Backbone 或其他任何东西上构建一个项目,并且您需要按特定顺序加载脚本,例如underscore.js 需要在 backbone.js 之前加载.

                如何让它连接脚本以使它们井井有条?

                //JS concat,剥离调试和缩小gulp.task('脚本', function() {gulp.src(['./source/js/*.js', './source/js/**/*.js']).pipe(concat('script.js')).pipe(stripDebug()).pipe(丑化()).pipe(gulp.dest('./build/js/'));});

                我的 source/index.html 中的脚本顺序正确,但由于文件是按字母顺序组织的,gulp 将在 之后连接 underscore.js>backbone.js,和我的source/index.html里面的脚本顺序无关,看目录下的文件.

                那么有人对此有什么想法吗?

                我最好的办法是用 123 重命名供应商脚本,以给它们正确的顺序,但我是不知道我喜不喜欢这个.

                随着我了解的更多,我发现 Browserify 是一个很好的解决方案,一开始可能会很痛苦,但它很棒.

                解决方案

                我最近在构建我的 AngularJS 应用程序时遇到了与 Grunt 类似的问题.这是我发布的一个问题.p>

                我最终做的是在 grunt 配置中按顺序显式列出文件.配置文件将如下所示:

                <代码>['/path/to/app.js','/path/to/mymodule/mymodule.js','/path/to/mymodule/mymodule/*.js']

                Grunt 能够找出哪些文件是重复的并且不包含它们.同样的技术也适用于 Gulp.

                Say, for example, you are building a project on Backbone or whatever and you need to load scripts in a certain order, e.g. underscore.js needs to be loaded before backbone.js.

                How do I get it to concat the scripts so that they’re in order?

                // JS concat, strip debugging and minify
                gulp.task('scripts', function() {
                    gulp.src(['./source/js/*.js', './source/js/**/*.js'])
                    .pipe(concat('script.js'))
                    .pipe(stripDebug())
                    .pipe(uglify())
                    .pipe(gulp.dest('./build/js/'));
                });
                

                I have the right order of scripts in my source/index.html, but since files are organized by alphabetic order, gulp will concat underscore.js after backbone.js, and the order of the scripts in my source/index.html does not matter, it looks at the files in the directory.

                So does anyone have an idea on this?

                Best idea I have is to rename the vendor scripts with 1, 2, 3 to give them the proper order, but I am not sure if I like this.

                As I learned more I found Browserify is a great solution, it can be a pain at first but it’s great.

                解决方案

                I had a similar problem recently with Grunt when building my AngularJS app. Here's a question I posted.

                What I ended up doing is to explicitly list the files in order in the grunt config. The config file will then look like this:

                [
                  '/path/to/app.js',
                  '/path/to/mymodule/mymodule.js',
                  '/path/to/mymodule/mymodule/*.js'
                ]
                

                Grunt is able to figure out which files are duplicates and not include them. The same technique will work with Gulp as well.

                这篇关于使用 Gulp 按顺序连接脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:SyntaxError: 'import' 和 'export' 可能只出 下一篇:Gulp.js 任务,返回 src?

                相关文章

                最新文章

                  <small id='33yQ5'></small><noframes id='33yQ5'>

                    <bdo id='33yQ5'></bdo><ul id='33yQ5'></ul>
                    <legend id='33yQ5'><style id='33yQ5'><dir id='33yQ5'><q id='33yQ5'></q></dir></style></legend>
                    <tfoot id='33yQ5'></tfoot>

                    <i id='33yQ5'><tr id='33yQ5'><dt id='33yQ5'><q id='33yQ5'><span id='33yQ5'><b id='33yQ5'><form id='33yQ5'><ins id='33yQ5'></ins><ul id='33yQ5'></ul><sub id='33yQ5'></sub></form><legend id='33yQ5'></legend><bdo id='33yQ5'><pre id='33yQ5'><center id='33yQ5'></center></pre></bdo></b><th id='33yQ5'></th></span></q></dt></tr></i><div id='33yQ5'><tfoot id='33yQ5'></tfoot><dl id='33yQ5'><fieldset id='33yQ5'></fieldset></dl></div>