我创建了一个config.json文件并在gulpfile.js中读取它
var config = require('./config.json')
如何将此配置对象传递给我的任务?
我的项目配置:
app / gulpfile.js - >在这里阅读JSON文件
var config = require('./config.json');
....
gulp.task('build',['scripts:build']);
我的任务 - >应用程序的/ dev /咽/ scripts.js中 .... 的console.log(配置)
StackTrace:
ReferenceError: config is not defined
at Object.<anonymous> (D:\app\dev\gulp\tasks\scripts.js:16:13)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at requireDir (D:\app\node_modules\require-dir\index.js:116:33)
at Object.<anonymous> (D:\app\gulpfile.js:7:1)
at Module._compile (module.js:460:26)