Error when using naming convention in Gulp

2019-08-20 11:43发布

问题:

I am working on this project using Zurb Foundation framework and it runs on Gulp. Basically what Gulp does is turn sass into css, compress, concatenate, etc. It runs perfect and it does what it’s suppose to do, UNTIL I try to change the name of the dist folder, where everything is built for production. The name I want to use is name-html5. The -html5 is a naming convention of 3dCart, so it needs the -html5 in the name of the folder. In gulpfile.babel.js I have:

// Delete the "dist" folder
// This happens every time a build starts
function clean(done) {
  rimraf(PATHS.dist, done);
}

If I substitute the dist for name-html5 I get a build error: ReferenceError: html5 is not defined because of the - in front of it. It just won’t take (PATHS.name-html5, done).

Also, I changed the name in config.yml file:

# Gulp will reference these paths when it copies files
PATHS:
  # Path to dist folder
  dist: "dist"  

but it didn't fix the issue. Any help?

回答1:

Instead of having a name-html5 property name, try taking out the hyphen. It can stay in the value.

# Gulp will reference these paths when it copies files
PATHS:
  # Path to dist folder
  dist: "dist"
  nameHtml5: "name-html5"

Then reference it as PATHS.nameHtml5