如何在gulp.config.js中指定文件?

时间:2016-03-23 11:49:25

标签: angularjs gulp

我正在使用gulp构建我的角度应用程序,但我似乎无法将所有源文件放在目录中。该目录名为./app/services,因此我在gulp.config.js中定义了这个:

  app_files: {
        // source, but NO specs
        js: ['app/*.js','app/services/**/*.js', '!src/**/*.spec.js'],

当我跑“gulp serve'我收到错误,无法找到目录app / services中的服务。当我将它移动到app目录时,我不会收到此消息,因此它必须是配置文件,其指定服务文件的方式不正确。如何指定configfile以包含app / services目录下的所有js文件?

1 个答案:

答案 0 :(得分:0)

对我来说,以下工作没有任何问题:

js: assetsFolder + "**/*.js",

完整示例包括其他:

var sources;

sources = {
  css: assetsFolder + "/stylesheets/**/*.less",
  coffee: {
    main: coffeeBaseFolder + "core/AppConfiguration.coffee",
    all: coffeeBaseFolder + '**/*.coffee',
    core: coffeeBaseFolder + 'core/*.coffee',
    controllers: coffeeBaseFolder + 'controllers/*.coffee',
    directives: coffeeBaseFolder + 'directives/*.coffee',
    filters: coffeeBaseFolder + 'filters/*.coffee',
    services: coffeeBaseFolder + 'services/*.coffee'
  },
  js: assetsFolder + "**/*.js",
  bower: ['bower.json', '.bowerrc'],
  bowerBase: "bower_components",
  images: assetsFolder + "images/**/*.*",
  sounds: assetsFolder + "sounds/**/*.*"
};

所以我会在你的情况下尝试"app/**/*.js"

更新

assetsFolder声明是:

var assetsFolder = "src/main/assets/"

在您的情况下,您不需要它,或者您可以放var assetsFolder="app/"