Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Coffeescript 大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口_Coffeescript_Gulp_Browserify - Fatal编程技术网

Coffeescript 大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口

Coffeescript 大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口大口,coffeescript,gulp,browserify,Coffeescript,Gulp,Browserify,我正试图找到一种很好的方法,通过browserify和gulp映射目录,这样我就没有太多的路径链接了: var uriparser = require('../../../app/assets/javascripts/app/module/mymodule.coffee') 所以我一直在尝试将remapify与gulp一起使用,所以我有如下配方: var gulp = require('gulp'); var browserify = require('browserify'); var re

我正试图找到一种很好的方法,通过browserify和gulp映射目录,这样我就没有太多的路径链接了:

var uriparser = require('../../../app/assets/javascripts/app/module/mymodule.coffee')
所以我一直在尝试将remapify与gulp一起使用,所以我有如下配方:

var gulp = require('gulp');
var browserify = require('browserify');
var remapify = require('remapify');
var source = require('vinyl-source-stream');

gulp.task("test", function () {
  var b = browserify({entries:['./spec/javascripts/modules/tests.coffee'],
    extensions: ['.coffee']
  });

  b.plugin(remapify, [
    {
      src: './app/assets/javascripts/app/**/*.coffee'
      , expose: 'app'
      , cwd:__dirname
    }

  ])



  libs.forEach(function (lib) {
    b.external(lib);
  });



  return b.bundle()
    .pipe(source("app.js"))
    .pipe(gulp.dest('./spec/javascripts/specs/helpers'));
});

不确定我遗漏了什么,但它只是没有正确地映射路径,也许这不是最好的工具,但已经尝试了很多选项,但都没有成功,所以任何帮助都将是巨大的

您至少有一个问题,原因是:


Remapify目前不支持像“coffee”这样的扩展。您可以先使用将CoffeeScript编译成JavaScript,然后重新映射它。

remapify现在尊重在browserify中配置的扩展列表。默认情况下,这是
js
json
,但您可以通过
extensions
browserify选项对其进行更改。不确定gulp中的格式是什么,但下面是我在grunt中所做的:

  grunt.initConfig
    browserify:
      app:
        dest: 'public/scripts/main.js'
        src: ['client/app/**/*.coffee']
        options:
          preBundleCB: (b) ->
            b.plugin remapify, [
              cwd: './client/app'
              src: '**/*.coffee'
              expose: 'app'
            ]

          transform: ['coffeeify']
          browserifyOptions:
            debug: true
            extensions: ['.coffee', '.js']