Skip to content

Commit 29e84a4

Browse files
committed
docs(serverless): terser config example
1 parent 71931fd commit 29e84a4

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

content/faq/serverless.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,22 @@ $ npx serverless offline
263263
Once the application is running, open your browser and navigate to `http://localhost:3000/dev/[ANY_ROUTE]` (where `[ANY_ROUTE]` is any endpoint registered in your application).
264264

265265
In the sections above, we've shown that using `webpack` and bundling your app can have significant impact on the overall bootstrap time.
266-
However, to make it work with our example, there's one additional configuration you must add in your `webpack.config.js` file. Generally,
267-
to make sure our `handler` function will be picked up, we must change the `output.libraryTarget` property to `commonjs2`.
266+
However, to make it work with our example, there are few additional configurations you must add in your `webpack.config.js` file. Generally,
267+
to make sure our `handler` function will be picked up, we must change the `output.libraryTarget` property to `commonjs2`. It's also recommended to install the `terser-webpack-plugin` package and override its configuration to keep classnames intact when minifying your production build. Not doing so can result in incorrect behavior when using `class-validator` within your application.
268268

269269
```javascript
270+
const TerserPlugin = require("terser-webpack-plugin");
271+
270272
return {
271273
...options,
272274
externals: [],
275+
optimization: {
276+
minimizer: [new TerserPlugin({
277+
terserOptions: {
278+
keep_classnames: true
279+
}
280+
})]
281+
},
273282
output: {
274283
...options.output,
275284
libraryTarget: 'commonjs2',

0 commit comments

Comments
 (0)