Serve: Alternative locations for configuration file

Created on 5 Jun 2018  路  3Comments  路  Source: vercel/serve

We are using serve as our local dev server for three.js. After upgrading to the latest version, I've realized we need cleanUrls set to false so our documentation still works with serve. The problem is now we don't want to pollute the root directory of the repo with even more files (see https://github.com/mrdoob/three.js/pull/14210). Is there a different way to pass in the mentioned configuration?

help wanted

Most helpful comment

+1, I use serve on a number of projects and cleanUrls=true seems like a very unexpected default setting to me. Adding another config file to the root of my projects would be nice to avoid. Some non-mutually exclusive alternatives:

  • Default to false as before
  • Allow configuration through a serve property in package.json
  • Allow setting the config file through a CLI parameter, like serve --config scripts/serve.json so developers can keep the top-level project clean
  • Provide a CLI parameter like serve --no-clean-urls

All 3 comments

+1, I use serve on a number of projects and cleanUrls=true seems like a very unexpected default setting to me. Adding another config file to the root of my projects would be nice to avoid. Some non-mutually exclusive alternatives:

  • Default to false as before
  • Allow configuration through a serve property in package.json
  • Allow setting the config file through a CLI parameter, like serve --config scripts/serve.json so developers can keep the top-level project clean
  • Provide a CLI parameter like serve --no-clean-urls

I would be happy to accept a PR for --config <path>... 馃槉 馃憤

Hi everyone, here's my naive attempt in implementing the --config flag.

  • The current implementation just accepts a raw String without any form of checks in place.

    • Running serve -c script/myServeConfig.json would work

    • Should we be enforcing a rule that serve's configuration can only be contained in an external file named serve.json? (other than now.json or package.json)

  • Should I be throwing an error if a file at <CUSTOM-PATH>/serve.json does not exists?

    • In this case mentioned above, currently serve will ignore it & attempt to parse other possible places containing the configurations in the following order: serve.json --> now.json --> package.json.

Would love to hear feedback from you guys 馃槄

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fabricionaweb picture fabricionaweb  路  3Comments

donmccurdy picture donmccurdy  路  6Comments

arel picture arel  路  4Comments

gaearon picture gaearon  路  4Comments

malinda1986 picture malinda1986  路  6Comments