- Notifications
You must be signed in to change notification settings - Fork50
⛔️ DEPRECATED ⛔️ Bundle with Browserify, transpile and minify with Babel automatically to your NodeJS runtime compatible JavaScript
License
Enigmatic-Smile/serverless-plugin-optimize
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This repository is no longer being maintained. Further developments to this repository can be made by forking the project.
Bundle with Browserify, transpile and minify with Babel automatically to your NodeJS runtime compatible JavaScript.
This plugin is a child of the greatserverless-optimizer-plugin. Kudos!
Requirements:
- Serverlessv1.12.x or higher.
- AWS provider and nodejs4.3/6.10/8.10/10.x/12.x/14.x runtimes
Install via npm in the root of your Serverless service:
npm install serverless-plugin-optimize --save-dev- Add the plugin to the
pluginsarray in your Serverlessserverless.yml:
plugins: -serverless-plugin-optimize
- Set your packages to be built individually to have smaller packages:
package:individually:true
- All done! Optimize will run on SLS
deployandinvoke localcommands
Configuration options can be set globally incustom property and inside each function inoptimize property. Function options overwrite global options.
- debug (default
false) - When debug is set totrueit won't removeprefixfolder and will generate debug output at the end of package creation. - exclude (default
['aws-sdk']) - Array of modules or paths that will be excluded. - extensions (default
['.js', '.json']) - Array of optional extra extensions modules that will be included. - external Array of modules to be copied into
node_modulesinstead of being loaded into browserify bundle. Note that external modules will require that its dependencies are within its directory and this pluginwill not do this for you. e.g. you should execute the following: (cd external_modules/some-module && npm i --prod) - externalPaths Optional object key value pair of external module name and path. If not set, external modules will look for reference path in
node_modules. - global (default
false) - When global is set totruetransforms will run insidenode_modules. - ignore - Array of modules or paths that won't be transformed with Babelify.
- includePaths - Array of file paths that will be included in the bundle package. Readhere how to call these files.
- minify (default
true) - When minify is set tofalseBabili preset won't be added. - plugins - Array of Babel plugins.
- prefix (default
_optimize) - Folder to output bundle. - presets (default
['env']) - Array of Babel presets.
custom:optimize:debug:trueexclude:['ajv']extensions:['.extension']external:['sharp']externalPaths:sharp:'external_modules/sharp'global:trueignore:['ajv']includePaths:['bin/some-binary-file']minify:falseprefix:'dist'plugins:['transform-decorators-legacy']presets:['es2017']
- optimize (default
true) - When optimize is set tofalsethe function won't be optimized.
functions:hello:optimize:false
- exclude - Array of modules or paths that will be excluded.
- extensions - Array of optional extra extensions modules that will be included.
- external Array of modules to be copied into
node_modulesinstead of being loaded into browserify bundle. Note that external modules will require it's dependencies within it's directory. (cd external_modules/some-module && npm i --prod) - externalPaths Optional object key value pair of external module name and path. If not set, external modules will look for reference path in
node_modules. - global - When global is set to
truetransforms will run insidenode_modules. - ignore - Array of modules or paths that won't be transformed with Babelify.
- includePaths - Array of file paths that will be included in the bundle package. Readhere how to call these files.
- minify - When minify is set to
falseBabili preset won't be added. - plugins - Array of Babel plugins.
- presets - Array of Babel presets.
functions:hello:optimize:exclude:['ajv']extensions:['.extension']external:['sharp']externalPaths:sharp:'external_modules/sharp'global:falseignore:['ajv']includePaths:['bin/some-binary-file']minify:false plugins:['transform-decorators-legacy'] presets:['es2017']
There is a difference you must know between calling files locally and after optimization withincludePaths.
When Optimize packages your functions, it bundles them inside/${prefix}/${functionName}/... and when your lambda function runs in AWS it will run from root/var/task/${prefix}/${functionName}/... and yourCWD will be/var/task/.
Solution in#32 by @hlegendre.path.resolve(process.env.LAMBDA_TASK_ROOT, ${prefix}, process.env.AWS_LAMBDA_FUNCTION_NAME, ${includePathFile}).
Help us making this plugin better and future proof.
- Clone the code
- Install the dependencies with
npm install - Create a feature branch
git checkout -b new_feature - Lint with standard
npm run lint
This software is released under the MIT license. Seethe license file for more details.
About
⛔️ DEPRECATED ⛔️ Bundle with Browserify, transpile and minify with Babel automatically to your NodeJS runtime compatible JavaScript
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors10
Uh oh!
There was an error while loading.Please reload this page.