M
M
Maxim Ivanov2016-11-06 13:00:36
npm
Maxim Ivanov, 2016-11-06 13:00:36

How to properly use a package script for different platforms?

I have this line in package.json

"scripts": {
      "default_linux": "export NODE_ENV=default&& export NODE_MINIFIED=false&& webpack",
      "default_windows": "set NODE_ENV=default&& set NODE_MINIFIED=false&& webpack",
      "default_linux_min": "export NODE_ENV=default&& export NODE_MINIFIED=true&& webpack",
      "default_windows_min": "set NODE_ENV=default&& set NODE_MINIFIED=true&& webpack",
  },

But it’s not very pleasant to run this, think about each version separately, etc., how to properly configure scripts for different platforms so that it’s one command, and not ..?
$ npm run default_linux # сборка фронтенда под linux

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Kitmanov, 2016-11-06
@splincodewd

Try cross-env , it will be something like this:

"scripts": {
  "default": "cross-env NODE_ENV=default NODE_MINIFIED=false webpack",
  "default_min": "cross-env NODE_ENV=default NODE_MINIFIED=true webpack"
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question