简体   繁体   English

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

[英]How to specify files in gulp.config.js?

I am using gulp to build my angular app, but I cant seem to get all the sourcefiles in a directory. 我正在使用gulp构建我的角度应用程序,但似乎无法在目录中获取所有源文件。 The directory is called ./app/services so I defined this in the gulp.config.js: 该目录称为./app/services,因此我在gulp.config.js中定义了此目录:

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

When I run 'gulp serve' I am getting an error that a service in the directory app/services cannot be found. 当我运行“ gulp serve”时,出现一个错误,即无法在目录app / services中找到服务。 When I move it to the app directory I dont get this message so it must be the config file which has an incorrect way of specifying the servicesfiles. 当我将其移至应用程序目录时,未收到此消息,因此它必须是配置文件,该文件具有指定服务文件的错误方式。 How can I specify the configfile to include all the js files under the app/services directory? 如何指定配置文件以将所有js文件包括在app / services目录下?

For me the following worked without any issues: 对我来说,以下工作没有任何问题:

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

Full Example including others: 完整示例,包括其他示例:

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/**/*.*"
};

So I would try "app/**/*.js" in your case. 因此,在您的情况下,我会尝试"app/**/*.js"

Update 更新资料

assetsFolder declaration is: assetFolder声明为:

var assetsFolder = "src/main/assets/"

In your case either you don't need it or you could put var assetsFolder="app/" . 在您的情况下,您不需要它,或者可以放入var assetsFolder="app/"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM