S
S
Sergey Tereshko2015-11-06 18:02:17
JavaScript
Sergey Tereshko, 2015-11-06 18:02:17

How to make wiredep ignore one line?

Good day.
My gulpfile.js has three tasks.
The first task is responsible for compiling jade templates into html files, including all dependencies from the bower.json manifest file using the wiredep plugin

gulp.task('jade', function() {
    gulp.src(config.path.dev.jade + '/index.jade')
    .pipe(jade({
        pretty: '\t'
    }))
    .pipe(wiredep({
        ignorePath: '../'
    }))
    .pipe(gulp.dest('./src'))
    .pipe(notify(config.message.jadeCompiled))
});

The result after executing this task is
<!-- bower:js-->
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/nodernizr-dev/modernizr-latest.js"></script>
<!-- endbower-->

The second task replaces the JQuery path with the one from the Google CDN using the gulp-google-cdn plugin
gulp.task('cdn', function () {
     return gulp.src('./src/index.html')
        .pipe(googlecdn(require('./bower.json')))
        .pipe(gulp.dest('./dist'))
        .pipe(notify(config.message.cdnComplete))
});

I get this result:
<!-- bower:js-->
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="bower_components/nodernizr-dev/modernizr-latest.js"></script>
<!-- endbower-->

The third task normalizes all paths to scripts, replacing them with production, by re-running wiredep
gulp.task('wiredep', function () {
    return gulp.src('./dist/index.html')
    .pipe(wiredep({
        ignorePath: '../src/bower_components/',
        exclude: 'jquery', // именно этой строчкой думал, что получится проигнорировать JQuery
        fileTypes: {
            html: {
                replace: {
                    js: '<script src="js/vendor/{{filePath}}"></script>',
                    css: '<link rel="stylesheet" href="css/vendor/{{filePath}}" />'
                }
            }
        }
    }))
    .pipe(gulp.dest('./dist'))
});

I get this result
<!-- bower:js-->
<script src="js/vendor/nodernizr-dev/modernizr-latest.js"></script>
<!-- endbower-->

And I want to get this one, i.e. I want jQuery path line to be ignored
<!-- bower:js-->
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="js/vendor/nodernizr-dev/modernizr-latest.js"></script>
<!-- endbower-->

Is it possible to do this?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question