Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
dist
.webpack
.serverless
coverage
.idea

.idea
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ module.exports = {
};
```

You can also let the plugin determine the correct handler entry points at build time.
Then you do not have to care anymore when you add or remove functions from your service:

```js
// webpack.config.js
const slsw = require('serverless-webpack');

module.exports = {
...
entry: slsw.lib.entries,
...
};
```

Note that, if the `output` configuration is not set, it will automatically be
generated to write bundles in the `.webpack` directory. If you set your own `output`
configuration make sure to add a [`libraryTarget`][link-webpack-libtarget]
Expand Down
15 changes: 15 additions & 0 deletions examples/babel-dynamically-entries/first.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
if (!global._babelPolyfill) {
require('babel-polyfill');
}

export const hello = (event, context, cb) => {
const p = new Promise((resolve, reject) => {
resolve('success');
});
p
.then(r => cb(null, {
message: 'Go Serverless Webpack (Babel) v1.0! First module!',
event,
}))
.catch(e => cb(e));
};
19 changes: 19 additions & 0 deletions examples/babel-dynamically-entries/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "serverless-webpack-babel-example",
"version": "1.0.0",
"description": "Serverless webpack example using Babel",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Nicola Peduzzi <[email protected]> (http://nikso.net)",
"license": "MIT",
"devDependencies": {
"babel-core": "^6.25.0",
"babel-loader": "^7.1.1",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-polyfill": "^6.23.0",
"babel-preset-env": "^1.6.0",
"serverless-webpack": "file:../../",
"webpack": "^3.3.0"
}
}
15 changes: 15 additions & 0 deletions examples/babel-dynamically-entries/second.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
if (!global._babelPolyfill) {
require('babel-polyfill');
}

export const hello = (event, context, cb) => {
const p = new Promise((resolve, reject) => {
resolve('success');
});
p
.then(r => cb(null, {
message: 'Go Serverless Webpack (Babel) v1.0! Second module!',
event,
}))
.catch(e => cb(e));
};
25 changes: 25 additions & 0 deletions examples/babel-dynamically-entries/serverless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
service: babel-dynamically-entries-example

# Add the serverless-webpack plugin
plugins:
- serverless-webpack

provider:
name: aws
runtime: nodejs4.3

functions:
first:
handler: first.hello
events:
- http:
method: get
path: first
integration: lambda
second:
handler: second.hello
events:
- http:
method: get
path: second
integration: lambda
20 changes: 20 additions & 0 deletions examples/babel-dynamically-entries/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const path = require('path');
const slsw = require('serverless-webpack');

module.exports = {
entry: slsw.lib.entries,
target: 'node',
module: {
loaders: [{
test: /\.js$/,
loaders: ['babel-loader'],
include: __dirname,
exclude: /node_modules/,
}]
},
output: {
libraryTarget: 'commonjs',
path: path.join(__dirname, '.webpack'),
filename: '[name]'
}
};
Loading