Browse Source

Explain how to set custom webpack.config output

master
Nicola Peduzzi 8 years ago
committed by GitHub
parent
commit
105b0509e5
  1. 23
      README.md

23
README.md

@ -32,9 +32,7 @@ custom:
webpack: ./folder/my-webpack.config.js
```
Note that, if the `output` configuration is not set, it will automatically be
generated to write bundles in the `.webpack` directory. An base Webpack
configuration might look like this:
An base Webpack configuration might look like this:
```javascript
// webpack.config.js
@ -48,6 +46,25 @@ module.exports = {
};
```
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`](https://webpack.github.io/docs/configuration.html#output-librarytarget)
for best compatibility with external dependencies:
```javascript
// webpack.config.js
module.exports = {
// ...
output: {
libraryTarget: 'commonjs',
path: '.webpack',
filename: 'handler.js', // this should match the first part of function handler in serverless.yml
},
// ...
};
```
By default, the plugin will try to bundle all dependencies. However, you don't
want to include all modules in some cases such as selectively import, excluding
builtin package (aws-sdk) and handling webpack-incompatible modules. In this case,

Loading…
Cancel
Save