javascript - Webpack version 2.0 or above declares a __STAGE__ variable, and an error will be reported when referenced elsewhere, but version 1.0 does not report an error. Solution
高洛峰
高洛峰 2017-06-12 09:31:13
0
1
584

Code declaring __STAGE__ in webpack.dev.conf.js

new webpack.DefinePlugin({
   'process.env': config.dev.env,
   __STAGE__: "'dev'"
 }),

The code quoted in reqData.js is as follows

req: function (p) {
    const req_obj = getReqObj(p)
    if (__STAGE__ === 'dev') {
      // console.log(__STAGE__)
      req_obj.apiName = p.apiName
      return test(req_obj)
    }
    delete req_obj.apiName
    return $ajax(req_obj)
  },

The same code, why does our project code not report an error when npm run dev, and can print out this variable, but the project I wrote myself reports an error when sending a request with this configuration. Is it because of the version? The company uses version 1.0, and mine is version 2.0.

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(1)
给我你的怀抱

Just re-run the command npm run dev. What a trap!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template