Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Getting Started with Gulp ??? Second Edition

You're reading from   Getting Started with Gulp ??? Second Edition Automating web development workflows

Arrow left icon
Product type Paperback
Published in Apr 2017
Publisher Packt
ISBN-13 9781787283732
Length 132 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
 Maynard Maynard
Author Profile Icon Maynard
Maynard
Arrow right icon
View More author details
Toc

External configuration


As you create or expand your gulpfile, you may reach a point where you would prefer to separate your configuration into an additional file. This is a common issue that arises as users get more comfortable with Gulp and wish to implement more control over how they configure their builds.

This can easily be done by creating an additional config.json file with each of the configuration options you would like to specify:

    {
        "js": {
            "src": ["app/js/*.js"],
            "dest": "dist"
        },
        "css": {
            "src": ["app/css/*.css"],
            "dest": "dist"
        }
    }

Then, we can include it in our gulpfile like all of our plugins and modules using a require function:

    var config = require('./config.json');

The only difference with this require function is that you must prepend it with ./ to tell node that this file will reside in the main project directory instead of the node_modules directory, where all of the other installed...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images