- This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
Viewing 7 posts - 1 through 7 (of 7 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Grunt directory variable
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
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.
Thanks for the reply!
Does it go inside grunt.initConfig({
or before it, or else?
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?
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.
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.