You've already forked serverless-webpack
mirror of
https://github.com/encounter/serverless-webpack.git
synced 2026-03-30 11:37:58 -07:00
bcd8dd65e6
Unit tests Added unit tests for copy modules packager flag npm must copy modules Fixed unit tests Yarn does not need to copy modules to be fast Install/prune unit tests. Fixed typo. Copy lock file only if it can be read. AAdjust unit tests. Copy lock file into function directories Only stringify JSON or YML lock files Fixed unit tests Add basic Yarn functionality
83 lines
1.7 KiB
JavaScript
83 lines
1.7 KiB
JavaScript
'use strict';
|
|
/**
|
|
* Plugin configuration.
|
|
*/
|
|
|
|
const _ = require('lodash');
|
|
|
|
/**
|
|
* Plugin defaults
|
|
*/
|
|
const DefaultConfig = {
|
|
webpackConfig: 'webpack.config.js',
|
|
includeModules: false,
|
|
packager: 'npm',
|
|
packagerOptions: {},
|
|
packExternalModulesMaxBuffer: 200 * 1024,
|
|
config: null
|
|
};
|
|
|
|
class Configuration {
|
|
|
|
constructor(custom) {
|
|
|
|
this._config = {};
|
|
this._hasLegacyConfig = false;
|
|
|
|
// Set configuration from sls.service.custom. We fall back to the
|
|
// old configuration to keep backwards compatibility.
|
|
if (custom) {
|
|
if (custom.webpackIncludeModules) {
|
|
this._config.includeModules = custom.webpackIncludeModules;
|
|
this._hasLegacyConfig = true;
|
|
}
|
|
if (custom.packExternalModulesMaxBuffer) {
|
|
this._config.packExternalModulesMaxBuffer = custom.packExternalModulesMaxBuffer;
|
|
this._hasLegacyConfig = true;
|
|
}
|
|
if (_.isString(custom.webpack)) {
|
|
this._config.webpackConfig = custom.webpack;
|
|
this._hasLegacyConfig = true;
|
|
} else {
|
|
_.assign(this._config, custom.webpack || {});
|
|
}
|
|
}
|
|
|
|
// Set defaults for all missing properties
|
|
_.defaults(this._config, DefaultConfig);
|
|
}
|
|
|
|
get webpackConfig() {
|
|
return this._config.webpackConfig;
|
|
}
|
|
|
|
get includeModules() {
|
|
return this._config.includeModules;
|
|
}
|
|
|
|
get packExternalModulesMaxBuffer() {
|
|
return this._config.packExternalModulesMaxBuffer;
|
|
}
|
|
|
|
get packager() {
|
|
return this._config.packager;
|
|
}
|
|
|
|
get packagerOptions() {
|
|
return this._config.packagerOptions;
|
|
}
|
|
|
|
get config() {
|
|
return this._config.config;
|
|
}
|
|
|
|
get hasLegacyConfig() {
|
|
return this._hasLegacyConfig;
|
|
}
|
|
|
|
toJSON() {
|
|
return _.omitBy(this._config, _.isNil);
|
|
}
|
|
}
|
|
|
|
module.exports = Configuration; |