-2

I want to extend the npm run build command in my package.json not by replacing it, because it uses react-scripts build but by &&'ing another script.

Fastest way to achieve this would be a bash script which just does that. I want to copy a few other files from src into build in order to make a chrome extension out of it.

Is it considered bad practice to use a shell script here rather than writing it natively in a node environment?

Mahoni
  • 7,088
  • 17
  • 58
  • 115
  • I wouldn't say bad practice but this is more of an opinionated question.. I would however, consider using a build tool such as gulp or leveraging npm lifecycle pre and post directives here is what might be a useful resource https://www.keithcirkel.co.uk/how-to-use-npm-as-a-build-tool/ – Somo S. Mar 11 '17 at 00:16
  • A shell script works fine, unless your script needs to run on windows. – RyanZim Mar 11 '17 at 00:50

1 Answers1

1

Not exactly a bad practice and it is often done in practice but keep in mind that it will be less portable because it will not work on systems where the shell that you use for scripting (e.g. Bash or whatever is in the shebang line) is not available.

I recently wrote an answer to the question on how to solve a problem with installing Node modules that require Bash on Windows:

So it is a problem that happens in practice.

Community
  • 1
  • 1
rsp
  • 107,747
  • 29
  • 201
  • 177