Gulp wiredep排除了jquery被注入

时间:2017-06-13 10:16:36

标签: javascript gulp wiredep

我正在使用wiredep来注入脚本,但我不希望注入jquery。我正在使用wiredep exclude选项来排除jquery,但它确实被注入了。如何排除jquery被wiredep注入。 下面是bower.json

{
  "name": "people10-code-challenge",
  "description": "People10 Code Challenge",
  "main": "app.js",
  "authors": [
    "Mahtab Alam"
  ],
  "license": "MIT",
  "keywords": [
    "nodejs",
    "angularjs",
    "mongodb",
    "express"
  ],
  "homepage": "https://github.com/eMahtab/people10-code-challenge",
  "ignore": [
    "**/.*",
    "node_modules",
    "bower_components",
    "app/client/vendor",
    "test",
    "tests"
  ],
  "dependencies": {
    "angular": "1.6.4",
    "bootstrap-additions": "^0.3.1",
    "AngularJS-Toaster": "angularjs-toaster#^2.1.0",
    "bootstrap": "^3.3.7",
    "angular-strap": "^2.3.12"
  }
}

这是gulpfile.js

"use strict"

var gulp = require('gulp'),
    jshint = require('gulp-jshint'),
    stylish = require('jshint-stylish'),
    wiredep = require('wiredep').stream,
    paths = {
        js:['./app/client/js/**/*.js','./app/client/app.js','./app/server/**/*.js']
    };

gulp.task('jshint',function(){
    return gulp.src(paths.js)
           .pipe(jshint())
           .pipe(jshint.reporter(stylish));
})    


var wiredepOptions = {  
  directory: 'app/client/public/vendor',
  exclude: ['jquery']
};


// Inject Bower components
gulp.task('wiredep', function () {

    gulp.src(['app/client/public/index.html'])
        .pipe(wiredep({wiredepOptions}))
        .pipe(gulp.dest('build'));    
});

1 个答案:

答案 0 :(得分:0)

知道了,wiredepOptions已经是我将它包装在一个对象中的对象。刚刚直接传递了wiredepOptions对象,它起作用了。我的坏。