My Gruntfile.js
contains a task for Compass:
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// FILE PATHS (custom)
dir: {
css: 'resources/styles/css',
fonts: 'resources/fonts',
html: 'resources/html',
images: 'resources/images',
includes: 'resources/includes',
node_modules: 'node_modules',
prototypes: 'resources/html/prototypes',
resources: 'resources',
scripts: 'resources/scripts',
scss: 'resources/styles/scss',
styles: 'resources/styles',
styleguide: 'resources/styleguide',
vendor: 'resources/vendor',
user: {
htdocs: '/Volumes/VR\ Mini\ Backup/Backups/Web/Active/myproject/htdocs'
}
},
// COMPASS
compass: {
dist: {
options: {
...
importPath: [
'<%= dir.user.htdocs %>/<%= dir.resources %>/vendor',
'<%= dir.user.htdocs %>/<%= dir.resources %>/fonts'
]
One of the Compass options is importPath
. This expects an absolute/system path. An example importPath
is /system/path/to/htdocs/resources/vendor
.
As several developers will be working on my project, I'd like to make /system/path/to/htdocs
dynamic.
Is there any way to access the path to Gruntfile.js
from within this file?
Thanks.
Installing the CLI. Run sudo npm install -g grunt-cli (Windows users should omit "sudo ", and may need to run the command-line with elevated privileges). The grunt command-line interface comes with a series of options. Use grunt -h from your terminal to show these options.
Grunt is a JavaScript task runner, a tool used to automatically perform frequent tasks such as minification, compilation, unit testing, and linting. It uses a command-line interface to run custom tasks defined in a file (known as a Gruntfile). Grunt was created by Ben Alman and is written in Node. js.
grunt-templateby Mathias BynensGrunt plugin that interpolates template files with any data you provide and saves the result to another file. web-component-testerby The Polymer Project Authorsweb-component-tester makes testing your web components a breeze!
You can leverage Node's path module.
At the top of your gruntfile, add var path = require('path');
.
path.resolve()
will give you the absolute path.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With