A serverless framework plugin to serve static files locally
Requires Node 10.
It's recommended to use this plugin along with serverless-offline.
Obviously, you should have Serverless-framework installed. If it's not, please start from this guide.
Then install the package:
npm install serverless-plugin-static -DYou can start serving the static folder by the CLI command, but probably for local development you should use serverless-offline plugin:
npm install serverless-offline -DAdd the plugins to your serverless.yml:
plugins:
- serverless-plugin-static
- serverless-offlineConfigure the plugin by providing folder path and server port, default values are:
custom:
static:
folder: ./static
port: 8080Start the application:
serverless offline startYou can also start serving files separately by the command:
serverless serve --folder ./static --port 8080Or with the shortcuts:
serverless serve -f ./static -p 8080Note: do not use CLI options with serverless-offline start command or any other plugins that create a server, since port argument will cause conflicts.