Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Grunt directory variable

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #158540
    Nathan Gross
    Participant

    I’m very new to JavaScript and even more new to Grunt.

    The short:

    How could I set up a variable in my Grunt.js file that points to a specific directory that I could call throughout my Grunt file.

    Something like:

    theme_location = “wp-content/themes/Custom_Theme/”

    The long:

    I’m working on setting up a generic WordPress project that utilizes grunt. Our workflow includes adding WordPress as a submodule (Git). So our file structure is a bit deeper than just a WordPress theme. Something like:

    Project
        wordpress (submodule)
        wp-content
            themes
                Custom_Theme
                    _
                        components
                            scss
                            js
                    css
                    js
        package.json
        Gruntfile.js
        config.rb
    
    #158541
    Melindrea
    Participant

    It’s actually almost as easy as that.

    In the config, add theme_location: 'wp-content/themes/Custom_Theme/', and you can then reference it using '<%= theme_location %>' in other parts of the config.

    #158542
    Nathan Gross
    Participant

    Thanks for the reply!

    Does it go inside grunt.initConfig({ or before it, or else?

    #158547
    Alen
    Participant

    Check out roots.io.

    #158549
    Nathan Gross
    Participant

    Alen,

    Thanks for the reply. While roots looks pretty interesting, and I’m sure I’ll find some helpful info within their documentation, I didn’t see anything about them using variables within their Grunt.js file.

    Did I miss something?

    #158550
    Alen
    Participant

    Sorry I couldn’t be more helpful, I’m just experimenting with Grunt as well. Just thought roots would be helpful in some way to you.

    #158551
    Nathan Gross
    Participant

    That makes sense :) I just thought maybe there was something specific that I had missed.

    Their docs and videos look pretty helpful. I’ve been watching a video series on Lynda.com.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.