Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

Commit

Permalink
fix: Evaluate custom options after hook fix Enigmatic-Smile#103
Browse files Browse the repository at this point in the history
  • Loading branch information
sammort committed Oct 16, 2020
1 parent 51c46f6 commit b5836c2
Showing 1 changed file with 63 additions and 63 deletions.
126 changes: 63 additions & 63 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,69 +82,6 @@ class Optimize {
}
}

/** Set custom options */
if (this.custom && this.custom.optimize) {
/** Debug flag */
if (this.custom.optimize.debug === true) {
this.optimize.options.debug = this.custom.optimize.debug
}

/** Exclude */
if (Array.isArray(this.custom.optimize.exclude)) {
this.optimize.options.exclude = this.custom.optimize.exclude
}

/** External */
if (Array.isArray(this.custom.optimize.external)) {
this.optimize.options.external = this.custom.optimize.external
}

/** External Paths */
if (typeof this.custom.optimize.externalPaths === 'object') {
this.optimize.options.externalPaths = this.custom.optimize.externalPaths
}

/** Extensions */
if (Array.isArray(this.custom.optimize.extensions)) {
this.optimize.options.extensions = this.custom.optimize.extensions
}

/** Global transforms */
if (typeof this.custom.optimize.global === 'boolean') {
this.optimize.options.global = this.custom.optimize.global
}

/** Include paths */
if (Array.isArray(this.custom.optimize.includePaths)) {
this.optimize.options.includePaths = this.custom.optimize.includePaths
}

/** Ignore */
if (Array.isArray(this.custom.optimize.ignore)) {
this.optimize.options.ignore = this.custom.optimize.ignore
}

/** Minify flag */
if (typeof this.custom.optimize.minify === 'boolean') {
this.optimize.options.minify = this.custom.optimize.minify
}

/** Babel plugins */
if (Array.isArray(this.custom.optimize.plugins)) {
this.optimize.options.plugins = this.custom.optimize.plugins
}

/** Optimize prefix */
if (typeof this.custom.optimize.prefix === 'string') {
this.optimize.options.prefix = this.custom.optimize.prefix
}

/** Babel presets */
if (Array.isArray(this.custom.optimize.presets)) {
this.optimize.options.presets = this.custom.optimize.presets
}
}

/** Serverless hooks */
this.hooks = {
'after:package:function:package': this.afterCreateDeploymentArtifacts.bind(this),
Expand All @@ -169,6 +106,69 @@ class Optimize {
/** Log optimize start */
this.serverless.cli.log('Optimize: starting engines')

/** Set custom options */
if (this.custom && this.custom.optimize) {
/** Debug flag */
if (this.custom.optimize.debug === true) {
this.optimize.options.debug = this.custom.optimize.debug
}

/** Exclude */
if (Array.isArray(this.custom.optimize.exclude)) {
this.optimize.options.exclude = this.custom.optimize.exclude
}

/** External */
if (Array.isArray(this.custom.optimize.external)) {
this.optimize.options.external = this.custom.optimize.external
}

/** External Paths */
if (typeof this.custom.optimize.externalPaths === 'object') {
this.optimize.options.externalPaths = this.custom.optimize.externalPaths
}

/** Extensions */
if (Array.isArray(this.custom.optimize.extensions)) {
this.optimize.options.extensions = this.custom.optimize.extensions
}

/** Global transforms */
if (typeof this.custom.optimize.global === 'boolean') {
this.optimize.options.global = this.custom.optimize.global
}

/** Include paths */
if (Array.isArray(this.custom.optimize.includePaths)) {
this.optimize.options.includePaths = this.custom.optimize.includePaths
}

/** Ignore */
if (Array.isArray(this.custom.optimize.ignore)) {
this.optimize.options.ignore = this.custom.optimize.ignore
}

/** Minify flag */
if (typeof this.custom.optimize.minify === 'boolean') {
this.optimize.options.minify = this.custom.optimize.minify
}

/** Babel plugins */
if (Array.isArray(this.custom.optimize.plugins)) {
this.optimize.options.plugins = this.custom.optimize.plugins
}

/** Optimize prefix */
if (typeof this.custom.optimize.prefix === 'string') {
this.optimize.options.prefix = this.custom.optimize.prefix
}

/** Babel presets */
if (Array.isArray(this.custom.optimize.presets)) {
this.optimize.options.presets = this.custom.optimize.presets
}
}

/** Get prefix path */
this.path = this.getPath(this.optimize.options.prefix)

Expand Down

0 comments on commit b5836c2

Please sign in to comment.