简体   繁体   English

从gulp传递变量到JS文件

[英]Pass variable from gulp to JS file

I want to pass process.ENV.TEST variable that is accessible in gulpfile.js to the local file I am using (and which I include in index.html ). 我想将gulpfile.js可访问的process.ENV.TEST变量传递给我正在使用的本地文件(并且我将其包含在index.html )。 How can I do that? 我怎样才能做到这一点?

server.use(express.static('./app'));
server.listen(SERVER_PORT);

I want to pass this variable to one of the files within the ./app directory - is this possible? 我想将此变量传递给./app目录中的文件之一-这可能吗?

you can use yargs npm plugin, to accept arguments 您可以使用yargs npm插件来接受参数

// install --save-dev yargs

var yargs = require('yargs');

//To access use
yargs.argumentName

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM