neutrinojs / neutrino

Create and build modern JavaScript projects with zero initial configuration.
https://neutrinojs.org
Mozilla Public License 2.0
3.95k stars 213 forks source link

Can we have the Neutrino Inspect command support custom configuration? #1609

Closed SilvaQ closed 4 years ago

SilvaQ commented 4 years ago

Code location

https://github.com/neutrinojs/neutrino/blob/b4edf55ac5056b5b5a952a980b5dc45b9045cd3c/packages/neutrino/bin/neutrino.js#L9

Feature request or enhancement?

When the neutrino Inspect command is executed want to specify a custom configuration, like:

yarn neutrino --mode production --config .custom.neutrino.js --inspect

I'm debugging locally below the code:

  let middleware = require(join(process.cwd(),'.neutrinorc.js'))
  if(Object.keys(argv).indexOf("config")){
    middleware =require(join(process.cwd(), argv.config))
  }
  neutrino(middleware).inspect();

the full code:

#!/usr/bin/env node

const yargsParser = require('yargs-parser');
const neutrino = require('..');
const { join } = require("path")

const argv = yargsParser(process.argv.slice(2));

if (argv.inspect) {
  let  middleware =require(join(process.cwd(), '.neutrinorc.js'))
  if(Object.keys(argv).indexOf("config")){
    middleware =require(join(process.cwd(), argv.config))
  }
  neutrino(middleware).inspect();
  process.exit();
}

console.error(`
The "neutrino start/build/lint/test" commands were removed in Neutrino 9.
Please see the migration guide for how to upgrade your project:
https://neutrinojs.org/migration-guide/

You may still inspect the generated webpack configuration using:
neutrino --inspect --mode {production,development}
`);

process.exit(1);
edmorley commented 4 years ago

@SilvaQ Hi! This sounds like a good idea. We'd be happy to accept a PR that adds support for this :-) (I don't have a huge amount of time to work on Neutrino these days, so would need someone else to write the PR.)

SilvaQ commented 4 years ago

@SilvaQ Hi! This sounds like a good idea. We'd be happy to accept a PR that adds support for this :-) (I don't have a huge amount of time to work on Neutrino these days, so would need someone else to write the PR.)

@edmorley

ok, no problem, I will try to submit a PR on this.

SilvaQ commented 4 years ago

@edmorley Hi, When can I use this function according to your plan?