- Notifications
You must be signed in to change notification settings - Fork 2
Options
You can configure how netlify-local will operate by specifying options within the netlify.toml
file using the plugins.local
namespace, or alternatively, you can set these options via command line arguments when issuing a command.
Command line arguments will override netlify.toml
options.
The following example describes how you could configure netlify-local using command line arguments or netlify.toml
to the same effect.
--netlify netlify.toml --webpack webpack.config.js --static false --lambda true --certificates private/certs --port 3000
[plugins.local.webpack] config = "webpack.config.js" [plugins.local.server] static = false lambda = true certificates = "private/certs" port = 3000
argument | toml property | type | default |
---|---|---|---|
-n --netlify | - | string | netlify.toml |
If for some odd reason you'd like to specify a netlify.toml
configuration which isn't located in the same relative directory or has a different name you can specify it with this option.
For obvious reasons it is redundant to specify the relative path to the netlify.toml
from within the netlify.toml
.
argument | toml property | type | default |
---|---|---|---|
-w --webpack | plugins.local.webpack.config | string | undefined |
Allows you to specify a webpack configuration file and process your files using a Webpack compiler.
There are no plans to support additional build tools.
argument | toml property | type | default |
---|---|---|---|
-h --hmr | plugins.local.webpack.hmr | string | undefined |
Allows you to specify if hmr should be enabled within webpack using the webpack-hot-middleware
package.
argument | toml property | type | default |
---|---|---|---|
-c --context | - | string | current git branch |
Allows you to specify which build context should be used.
argument | toml property | type | default |
---|---|---|---|
-s --static | plugins.local.server.static | boolean | true |
Allows you to toggle the static router from being initialized.
argument | toml property | type | default |
---|---|---|---|
-l --lambda | plugins.local.server.lambda | boolean | true |
Allows you to toggle the lambda router from being initialized.
argument | toml property | type | default |
---|---|---|---|
-p --port | plugins.local.server.port | number | 9000 |
Allows you to set the port which the server should bind on.
argument | toml property | type | default |
---|---|---|---|
--certificates | plugins.local.server.certificates | string | undefined |
Allows you to enable https support, the value should be a relative path to a directory containing a private key file named key.pem
and certificate file named cert.pem
.
If you're not sure how to create certificates for local development you can use the one-liner below to create a directory named private/certs
and generate them - optionally you can save and run this as an npm script.
mkdir -p private/certs && openssl req -x509 -sha256 -nodes -newkey rsa:2048 -days 365 -keyout private/certs/key.pem -out private/certs/cert.pem -subj '/CN=localhost' &> /dev/null
argument | toml property | type | default |
---|---|---|---|
- | plugins.local.functions.config | string | functions |
Allows you to specify which Webpack Configuration should be used based on the configuration name
property.
argument | toml property | type | default |
---|---|---|---|
- | plugins.local.functions.source | string | <empty string> |
Allows you to specify the base or source directory where your functions are located.
argument | toml property | type | default |
---|---|---|---|
- | plugins.local.functions.files | Array<string> | undefined |
Allows you to specify your functions by their file path, relative to the plugins.local.functions.source
property.