我有一个gulpfile,从中我启动webpack打包。webpack配置中定义了一个别名,使用process.env.NODE_ENV
如下所示:
.
.
resolve: {
modulesDirectories: ["node_modules", "js", "jsx"],
extensions: ["", ".js", ".jsx"],
alias: {
config: path.join(__dirname, ('config.' + process.env.NODE_ENV + '.js'))
}
}..
在 gulpfile 中,我有两个任务按顺序执行。
set-env
that sets the environment variable usinggulp-env
as followsgulpEnv({ vars: { NODE_ENV: 'dev' } });
webpack
task that depends on the previous task and executes only when the first is completed
看起来变量没有被正确地注入。文件名被解析为config.undefined.js
。我做错了什么吗?