Javascript 带browserify的条件要求

Javascript 带browserify的条件要求,javascript,node.js,gruntjs,browserify,Javascript,Node.js,Gruntjs,Browserify,对于browserify,我试图只在开发时需要一个模块。出于某种原因,它也总是被包括在生产中 NPM脚本: "start": "export NODE_ENV=development&& grunt watch & grunt serve", "prod": "export NODE_ENV=production&& grunt prod" 组件需要: const isProduction = process.env.NODE_ENV === 'prod

对于browserify,我试图只在开发时需要一个模块。出于某种原因,它也总是被包括在生产中

NPM脚本:

"start": "export NODE_ENV=development&& grunt watch & grunt serve",
"prod": "export NODE_ENV=production&& grunt prod"
组件需要:

const isProduction = process.env.NODE_ENV === 'production';

require('animation.gsap');

if (!isProduction) {
   require('debug.addIndicators');
}

在编译时浏览捆绑包。所以它不知道你的变量。检查这个包裹。它可以解决你的问题(尽管我没有用过)。捆绑时,可以为不同的环境设置不同的上下文