Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

⛔️ DEPRECATED ⛔️ Bundle with Browserify, transpile and minify with Babel automatically to your NodeJS runtime compatible JavaScript

License

NotificationsYou must be signed in to change notification settings

Enigmatic-Smile/serverless-plugin-optimize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repository is no longer being maintained. Further developments to this repository can be made by forking the project.

Serverless Optimize Plugin

No Maintenance Intendedserverlessnpm versionnpm downloadslicense

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

Setup

Install via npm in the root of your Serverless service:

npm install serverless-plugin-optimize --save-dev
  • Add the plugin to theplugins array 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 SLSdeploy andinvoke local commands

Options

Configuration options can be set globally incustom property and inside each function inoptimize property. Function options overwrite global options.

Global

  • debug (defaultfalse) - When debug is set totrue it won't removeprefix folder 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 intonode_modules instead 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 innode_modules.
  • global (defaultfalse) - When global is set totrue transforms 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 (defaulttrue) - When minify is set tofalse Babili 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']

Function

  • optimize (defaulttrue) - When optimize is set tofalse the 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 intonode_modules instead 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 innode_modules.
  • global - When global is set totrue transforms 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 tofalse Babili 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']

includePaths Files

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}).

Contribute

Help us making this plugin better and future proof.

  • Clone the code
  • Install the dependencies withnpm install
  • Create a feature branchgit checkout -b new_feature
  • Lint with standardnpm run lint

License

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

Stars

Watchers

Forks

Packages

No packages published

Contributors10


[8]ページ先頭

©2009-2025 Movatter.jp