Allow users to specify port in superstatic.json file
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.
How are you using Superstatic? From the command line or programmatically?
Command line. Right now I'm typing superstatic --port 8080, would love to just hit superstatic/ss and go!
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"
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.
+1
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.
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.