superstatic icon indicating copy to clipboard operation
superstatic copied to clipboard

Allow users to specify port in superstatic.json file

Open soluml opened this issue 11 years ago • 7 comments

I'm probably missing something obvious; but it doesn't look like I can specify a port value in the config file!

We're restricted to a single port due to CORS, so it'd be handy to have this number in the superstatic.json file in version control.

soluml avatar May 13 '15 22:05 soluml

How are you using Superstatic? From the command line or programmatically?

scottcorgan avatar May 13 '15 22:05 scottcorgan

Command line. Right now I'm typing superstatic --port 8080, would love to just hit superstatic/ss and go!

soluml avatar May 13 '15 22:05 soluml

We have discussed this back and forth quite a bit. One of our main arguments for not doing this is that the config JSON file is settings/options to configure how your application handles your files and less on how the server runs (hence --port and --host are not included as options in that file)

You can write an alias if you'd like in your ~/.bash_profile file as alias static="superstatic --port 8080"

scottcorgan avatar Jun 19 '15 15:06 scottcorgan

Well the reason behind wanting it in the config was that I could check the superstatic.json file into Git and any coworker could fire it up on the same port, simplifying setup instructions. Being able to say "type 'ss' in the console" was really appealing. If it was just me using it, I wouldn't have an issue with just using --port.

soluml avatar Jun 23 '15 15:06 soluml

+1

bl1nkr avatar Jul 24 '15 20:07 bl1nkr

There is another option, which is, in my opinion, a better option. Since the port and host have nothing to do with the app itself, putting this information in your package.json scripts fields seems like the best way to get it into your repo.

{
  "name": "my-app",
  "version": "1.0.0",
  "scripts": {
    "start": "superstatic --port 3000"
  }
}

Then you can just run npm start from the command line.

This also gets the benefit of abstracting the start command from the actually implementation.

scottcorgan avatar Sep 22 '15 16:09 scottcorgan

Things that go into superstatic.json are intended to be content-level configuration, not server-level confioguration. For that reason, I'm not willing to support spec-level information (like port) in that file. Recommended would be to use Scott's workaround as described above with NPM script runners or even just a simple bash script that can be run from the project directory.

mbleigh avatar Dec 11 '15 21:12 mbleigh