Skip to content

Commit

Permalink
Merge pull request #269 from dror-weiss/feature/generate-stats-files
Browse files Browse the repository at this point in the history
Add `generageStatsFiles` flag
  • Loading branch information
jayair authored Nov 25, 2021
2 parents be33d11 + 74ccae7 commit 0de12ac
Show file tree
Hide file tree
Showing 37 changed files with 991 additions and 21,367 deletions.
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

0 comments on commit 0de12ac

Please sign in to comment.