React and Grunt - Envify NODE_ENV='production' and UglifyJS

前端 未结 3 1954
猫巷女王i
猫巷女王i 2021-02-15 17:19

I am using Grunt to build a React project and I want to have \'dev\' and \'prod\' flavours. As react docs says:

To use React in productio

3条回答
  •  情歌与酒
    2021-02-15 18:02

    Just an addition to the great answer by FakeRainBrigand, if you're running on Windows (like me) then you need a subtly different syntax in your scripts section:

    {
      "scripts": {
        "build": "SET NODE_ENV=development&&grunt build-dev",
        "dist": "SET NODE_ENV=production&&grunt dist"
      }
    },
    "devDependencies": {
      "grunt": "...",
      "grunt-cli": "..."
    }
    

提交回复
热议问题