无法在Webpack中定义Node_ENV

时间:2017-03-10 01:01:49

标签: configuration webpack feathersjs

我正在尝试使用webpack,但在使用feathers-configuration pack时遇到ENV问题:

Uncaught TypeError: Cannot read property 'getEnv' of undefined
        at Function.<anonymous> (vendor.npm.js:37275)
        at Function.configure (vendor.npm.js:27533)
        at Object.59 (index.js:38)
        at __webpack_require__ (manifest.js:51)
        at Object.0 (index.js:8)
        at __webpack_require__ (manifest.js:51)
        at webpackJsonpCallback (manifest.js:22)
        at index.js:1

vendor.npm.js包中的错误是。 Feathers-configuration使用config.getEnv方法,但找不到NODE_ENV。

var env = config.util.getEnv('NODE_ENV');

我甚至尝试使用defineplugin,但它不起作用:

new webpack.DefinePlugin({
                DEBUG: true,
                "process.env":{
                    "NODE_ENV": JSON.stringify("production")
                }
            }),

1 个答案:

答案 0 :(得分:0)

尝试使用以下插件https://www.npmjs.com/package/extended-define-webpack-plugin

// webpack.config.js

var ExtendedDefinePlugin = require('extended-define-webpack-plugin');
var appConfig = require('./app.config.js');

module.exports = {
  // ... 
  plugins: [
    /* ..., */
    new ExtendedDefinePlugin({
      APP_CONFIG: appConfig,
    })
  ]
};