insin / nwb

A toolkit for React, Preact, Inferno & vanilla JS apps, React libraries and other npm modules for the web, with no configuration (until you need it)
Other
5.57k stars 331 forks source link

Execute node script with nwb #281

Open kabriel opened 7 years ago

kabriel commented 7 years ago

This issue is a:

It would be great if I could create arbitrary node scripts and add them to my project and use nwb to execute them. This would be required so it would use the same settings as nwb; for example it would use the same babel configuration.

"scripts": { "tool": "nwb exec ./scripts/tool" }

Hopefully this makes sense. The above would let me use npm run tool and it would execute the ./scripts/tool js file and support the same code features (es6 etc) as the rest of my app.

insin commented 7 years ago

I've had similar thoughts about nwb exposing a way to run some of the tooling it's already managing dependencies for - e.g. I have to add and manage Babel and MochadevDependencies to transpile and test server code when I'm using nwb for Express middleware and client building/testing in the same project.

To whet the appetite:

nwb babel run ./scripts/tool --config=./scripts/tool.nwbconfig.js
nwb babel transpile src/ lib/ --config=server.nwbconfig.js
nwb mocha something something

I'd also add support for using babel-preset-env as part of this, as it's what I use for Node.js code.