Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add generageStatsFiles flag #269

Merged
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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ You can [read more about this over on Serverless Stack](https://serverless-stack
- [Support for pem, txt, and other raw files](#support-for-pem-txt-and-other-raw-files)
- [Externals](#externals)
- [Externals vs forceExclude](#externals-vs-forceexclude)
- [Generating a stats file](#generating-stats-files)
- [Support](#support)
- [Running Locally](#running-locally)

Expand Down Expand Up @@ -105,6 +106,7 @@ custom:
concurrency: 5 # Set desired concurrency, defaults to the number of available cores
stats: false # Don't print out any Webpack output
linting: true # Enable linting as a part of the build process
generateStatsFiles: false # Creates stats files that could be used for bundle analyzing, more below
esbuild: false # Use esbuild-loader instead of babel or ts for faster builds
disableForkTsChecker: false # Disable the ForkTsChecker plugin, more below
tsConfig: "tsconfig.json" # Path to your 'tsconfig.json', if it's not in the root
Expand Down Expand Up @@ -454,6 +456,12 @@ The three options (`externals`, `forceExclude`, and `excludeFiles`) look similar

These are a glob of files that can be excluded from the function resolution. This happens when you have multiple files that are in the same directory and Serverless Framework tries to use them as a function handler. For example, if you have a `index.js` and a `index.test.js` and your function is pointing to `index`, you'll get a warning saying, `WARNING: More than one matching handlers found for index. Using index.js`. To fix this, use `excludeFiles: **/*.test.js`.

### Generating stats files

Use the `generateStatsFiles` option if you want to analyze your bundle size. This option, if set to `true`, will
enable the generation of a `bundle_stats.json` and a `bundle_stats.html` in the output directory, using the
[webpack-bundle-analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer) plugin.

## Support

- Open a [new issue](https://github.com/AnomalyInnovations/serverless-bundle/issues/new) if you've found a bug or have some suggestions.
Expand Down
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ function applyWebpackOptions(custom, config) {
packagePath: path.relative(
config.servicePath,
pkgUp.sync({ cwd: config.servicePath })
),
)
},
excludeFiles: config.options.excludeFiles,
excludeRegex: /bundle_stats\.(html|json)$/,
keepOutputDirectory: config.options.generateStatsFiles
};
}

Expand Down
Loading