• <tfoot id='RgegQ'></tfoot>
    • <bdo id='RgegQ'></bdo><ul id='RgegQ'></ul>

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

      1. <legend id='RgegQ'><style id='RgegQ'><dir id='RgegQ'><q id='RgegQ'></q></dir></style></legend>
        <i id='RgegQ'><tr id='RgegQ'><dt id='RgegQ'><q id='RgegQ'><span id='RgegQ'><b id='RgegQ'><form id='RgegQ'><ins id='RgegQ'></ins><ul id='RgegQ'></ul><sub id='RgegQ'></sub></form><legend id='RgegQ'></legend><bdo id='RgegQ'><pre id='RgegQ'><center id='RgegQ'></center></pre></bdo></b><th id='RgegQ'></th></span></q></dt></tr></i><div id='RgegQ'><tfoot id='RgegQ'></tfoot><dl id='RgegQ'><fieldset id='RgegQ'></fieldset></dl></div>
      2. Gulp concat 和需要路径

        时间:2023-05-29
          <tbody id='9vPaK'></tbody>
      3. <legend id='9vPaK'><style id='9vPaK'><dir id='9vPaK'><q id='9vPaK'></q></dir></style></legend>
        <tfoot id='9vPaK'></tfoot>

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

              <small id='9vPaK'></small><noframes id='9vPaK'>

                  本文介绍了Gulp concat 和需要路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我对 gulp-concat 有疑问.我正在尝试将我的所有 js 文件连接到一个文件中,比如说 dist/app.js.

                  I have a problem with gulp-concat. I'm trying to concate all my js files in a single file, let's say, dist/app.js.

                  但是有些东西我不明白.在那个文件中,我需要的文件路径仍然和以前一样......

                  But there is something that I don't understand. In that file, my required files path are still the same than before...

                  这是我的 gulpfile.js :

                  Here is my gulpfile.js :

                  var gulp       = require("gulp");
                  var sourcemaps = require("gulp-sourcemaps");
                  var babel      = require("gulp-babel");
                  var concat     = require("gulp-concat");
                  var resolveDependencies      = require("gulp-resolve-dependencies");
                  
                  gulp.task("default", function () {
                    return gulp.src("client/**/*.js")
                      .pipe(sourcemaps.init())
                      .pipe(babel())
                      .pipe(concat("app.js"))
                      .pipe(sourcemaps.write("."))
                      .pipe(gulp.dest("dist/js"));
                  });
                  

                  如您所见,我想连接嵌套文件夹.

                  As you can see, I want to concat nested folders.

                  以我的/client/components/app.js 顶部为例:

                  Take a look for example at the top of my /client/components/app.js :

                  import React, {PropTypes} from 'react';
                  import AppLeftNav from './AppLeftNav';
                  import {AppCanvas, AppBar, Styles} from 'material-ui';
                  
                  //Code here
                  

                  所以在我由 gulp 生成的 app.js 中,我可以看到:

                  So in my app app.js generated by gulp, i can see :

                  var _AppLeftNav = require('./AppLeftNav');
                  

                  是相对路径,不能用.

                  那么,用相对路径处理这些所需文件的技巧是什么?

                  So, what's the tricks to handle theses required files with relative path ?

                  非常感谢.

                  查看我得到的错误:

                  Error: Cannot find module './components/App.js'
                      at Function.Module._resolveFilename (module.js:336:15)
                      at Function.Module._load (module.js:278:25)
                      at Module.require (module.js:365:17)
                      at require (module.js:384:17)
                      at Object.<anonymous> (MyFolderdistjsapp.js:34:24)
                      at Module._compile (module.js:460:26)
                      at Object.Module._extensions..js (module.js:478:10)
                      at Module.load (module.js:355:32)
                      at Function.Module._load (module.js:310:12)
                      at Module.require (module.js:365:17)
                  

                  推荐答案

                  致任何可能有同样问题的人.Babel 目前不支持内联导入 #1681,gulp-concat 也不支持,因为它是只是连接文件.

                  To anyone who might have the same problem. Babel currently doesn't support imports inlining #1681, neither do gulp-concat, as it's just concatenating files.

                  我选择使用 Rollup 来正确解决依赖关系,然后才转译输出:

                  I opted to use Rollup to propertly resolve dependencies and only then transpile output:

                  var gulp = require('gulp');
                  var gutil = require('gulp-util');
                  var babel = require('gulp-babel');
                  var concat = require('gulp-concat');
                  var rollup = require('gulp-rollup');
                  
                  gulp.task('build', function () {
                    return gulp.src('src/parser-factory.js', { read: false })
                      .pipe(rollup({ external: ['request', 'cheerio'] }))
                      .on('error', gutil.log)
                      .pipe(babel({ stage: 0 }))
                      .pipe(concat('realty-parser.js'))
                      .pipe(gulp.dest('lib'));
                  });
                  

                  这篇关于Gulp concat 和需要路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:从 webdriver.io 获取数据后动态构建 Mocha 测试 下一篇:Gulp注入不起作用

                  相关文章

                  最新文章

                  <legend id='DG7MA'><style id='DG7MA'><dir id='DG7MA'><q id='DG7MA'></q></dir></style></legend>
                  • <bdo id='DG7MA'></bdo><ul id='DG7MA'></ul>
                  <tfoot id='DG7MA'></tfoot>

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

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