Skip to content

Commit 4216e18

Browse files
committed
Tidy README.md, fix nitpicks and add badges
1 parent 3e8c33d commit 4216e18

File tree

1 file changed

+44
-25
lines changed

1 file changed

+44
-25
lines changed

README.md

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
# Serverless Webpack
22

3-
[![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com)
4-
[![CircleCI](https://circleci.com/gh/elastic-coders/serverless-webpack.svg?style=shield)](https://circleci.com/gh/elastic-coders/serverless-webpack)
3+
[![Serverless][ico-serverless]][link-serverless]
4+
[![CircleCI][ico-circleci]][link-circleci]
5+
[![NPM][ico-npm]][link-npm]
6+
[![Contributors][ico-contributors]][link-contributors]
57

6-
A Serverless v1.0 plugin to build your lambda functions with [Webpack](https://webpack.github.io).
8+
A Serverless v1.x plugin to build your lambda functions with [Webpack][link-webpack].
79

8-
This plugin is for you if you want to use the latest Javascript version with [Babel](https://babeljs.io/);
9-
use custom [resource loaders](https://webpack.github.io/docs/loaders.html);
10+
This plugin is for you if you want to use the latest Javascript version with [Babel][link-babel];
11+
use custom [resource loaders][link-webpack-loaders];
1012
try your lambda functions locally and much more!
1113

1214
> **BREAKING CHANGE IN v2**: `webpack` must now be installed alongside `serverless-webpack` as a peer dependency. This allows more control over which version of Webpack to run.
1315
1416
## Install
1517

16-
```
17-
npm install serverless-webpack
18+
```bash
19+
$ npm install serverless-webpack --save-dev
1820
```
1921

2022
Add the plugin to your `serverless.yml` file:
@@ -27,7 +29,7 @@ plugins:
2729
## Configure
2830
2931
By default the plugin will look for a `webpack.config.js` in the service directory.
30-
In alternative you can specify a different file or configuration in the `serverless.yml` with:
32+
Alternatively, you can specify a different file or configuration in `serverless.yml`:
3133

3234
```yaml
3335
custom:
@@ -36,7 +38,7 @@ custom:
3638

3739
An base Webpack configuration might look like this:
3840

39-
```javascript
41+
```js
4042
// webpack.config.js
4143
4244
module.exports = {
@@ -50,18 +52,18 @@ module.exports = {
5052

5153
Note that, if the `output` configuration is not set, it will automatically be
5254
generated to write bundles in the `.webpack` directory. If you set your own `output`
53-
configuration make sure to add a [`libraryTarget`](https://webpack.github.io/docs/configuration.html#output-librarytarget)
55+
configuration make sure to add a [`libraryTarget`][link-webpack-libtarget]
5456
for best compatibility with external dependencies:
5557

56-
```javascript
58+
```js
5759
// webpack.config.js
5860
5961
module.exports = {
6062
// ...
6163
output: {
6264
libraryTarget: 'commonjs',
6365
path: '.webpack',
64-
filename: 'handler.js', // this should match the first part of function handler in serverless.yml
66+
filename: 'handler.js', // this should match the first part of function handler in `serverless.yml`
6567
},
6668
// ...
6769
};
@@ -72,7 +74,7 @@ want to include all modules in some cases such as selectively import, excluding
7274
builtin package (ie: `aws-sdk`) and handling webpack-incompatible modules.
7375

7476
In this case you might add external modules in
75-
[Webpack `externals` configuration](https://webpack.github.io/docs/configuration.html#externals).
77+
[Webpack's `externals` configuration][link-webpack-externals].
7678
Those modules can be included in the Serverless bundle with the `webpackIncludeModules`
7779
option in `serverless.yml`:
7880

@@ -98,7 +100,7 @@ is stated as `dependencies` in `package.json`, it will be packed into the Server
98100
artifact under the `node_modules` directory.
99101

100102
By default, the plugin will use the `package.json` file in working directory, If you want to
101-
use a different package conf, set `packagePath` to your custom package.json. eg:
103+
use a different package file, set `packagePath` to your custom `package.json`:
102104

103105
```yaml
104106
# serverless.yml
@@ -108,15 +110,15 @@ custom:
108110
```
109111
> Note that only relative path is supported at the moment.
110112

111-
You can find an example setups in the [`examples`](./examples) folder.
113+
You can find an example setups in the [`examples`][link-examples] folder.
112114

113115
## Usage
114116

115117
### Automatic bundling
116118

117119
The normal Serverless deploy procedure will automatically bundle with Webpack:
118120

119-
- Create the Serverless project with `serverless create -t aws-node`
121+
- Create the Serverless project with `serverless create -t aws-nodejs`
120122
- Install Serverless Webpack as above
121123
- Deploy with `serverless deploy`
122124

@@ -126,8 +128,8 @@ To start a local server that will act like the API Gateway use the following com
126128
Your code will be reloaded upon change so that every request to your local server
127129
will serve the latest code.
128130

129-
```
130-
serverless webpack serve
131+
```bash
132+
$ serverless webpack serve
131133
```
132134

133135
Options are:
@@ -151,8 +153,8 @@ functions:
151153

152154
To run your bundled functions locally you can:
153155

154-
```
155-
serverless webpack invoke --function <function-name>
156+
```bash
157+
$ serverless webpack invoke --function <function-name>
156158
```
157159

158160
Options are:
@@ -164,8 +166,8 @@ Options are:
164166

165167
Or to run a function every time the source files change use `watch`:
166168

167-
```
168-
serverless webpack watch --function <function-name> --path event.json
169+
```bash
170+
$ serverless webpack watch --function <function-name> --path event.json
169171
```
170172

171173
Options are:
@@ -177,8 +179,8 @@ Options are:
177179

178180
To just bundle and see the output result use:
179181

180-
```
181-
serverless webpack --out dist
182+
```bash
183+
$ serverless webpack --out dist
182184
```
183185

184186
Options are:
@@ -187,8 +189,25 @@ Options are:
187189

188190
## Example with Babel
189191

190-
In the [`examples`](./examples) folder there is a Serverless project using this
192+
In the [`examples`][link-examples] folder there is a Serverless project using this
191193
plugin with Babel. To try it, from inside the example folder:
192194

193195
- `npm install` to install dependencies
194196
- `serverless webpack run -f hello` to run the example function
197+
198+
[ico-serverless]: http://public.serverless.com/badges/v3.svg
199+
[ico-circleci]: https://img.shields.io/circleci/project/github/elastic-coders/serverless-webpack.svg
200+
[ico-npm]: https://img.shields.io/npm/v/serverless-webpack.svg
201+
[ico-contributors]: https://img.shields.io/github/contributors/elastic-coders/serverless-webpack.svg
202+
203+
[link-serverless]: http://www.serverless.com/
204+
[link-circleci]: https://circleci.com/gh/elastic-coders/serverless-webpack/
205+
[link-npm]: https://www.npmjs.com/package/serverless-webpack
206+
[link-contributors]: https://github.com/elastic-coders/serverless-webpack/graphs/contributors
207+
208+
[link-webpack]: https://webpack.github.io/
209+
[link-babel]: https://babeljs.io/
210+
[link-webpack-loaders]: https://webpack.github.io/docs/loaders.html
211+
[link-webpack-libtarget]: https://webpack.github.io/docs/configuration.html#output-librarytarget
212+
[link-webpack-externals]: https://webpack.github.io/docs/configuration.html#externals
213+
[link-examples]: ./examples

0 commit comments

Comments
 (0)