diff --git a/src/s3_plugin.js b/src/s3_plugin.js index 46f6c4cc..5c630192 100644 --- a/src/s3_plugin.js +++ b/src/s3_plugin.js @@ -102,22 +102,22 @@ module.exports = class S3Plugin { let dPath = addSeperatorToPath(this.options.directory) this.getAllFilesRecursive(dPath) - .then((files) => this.handleFiles(files, cb)) + .then((files) => this.handleFiles(files, compilation)) .then(() => cb()) .catch(e => this.handleErrors(e, compilation, cb)) } else { this.getAssetFiles(compilation) - .then((files) => this.handleFiles(files)) + .then((files) => this.handleFiles(files, compilation)) .then(() => cb()) .catch(e => this.handleErrors(e, compilation, cb)) } }) } - handleFiles(files) { + handleFiles(files, compilation) { return this.changeUrls(files) .then((files) => this.filterAllowedFiles(files)) - .then((files) => this.uploadFiles(files)) + .then((files) => this.uploadFiles(files, compilation)) .then(() => this.invalidateCloudfront()) } @@ -229,8 +229,8 @@ module.exports = class S3Plugin { this.isConnected = true } - transformBasePath() { - return Promise.resolve(this.basePathTransform(this.options.basePath)) + transformBasePath(compilation) { + return Promise.resolve(this.basePathTransform(this.options.basePath, compilation)) .then(addTrailingS3Sep) .then(nPath => this.options.basePath = nPath) } @@ -268,8 +268,8 @@ module.exports = class S3Plugin { }) } - uploadFiles(files = []) { - return this.transformBasePath() + uploadFiles(files = [], compilation) { + return this.transformBasePath(compilation) .then(() => { var uploadFiles = files.map(file => this.uploadFile(file.name, file.path)) diff --git a/test/upload_test.js b/test/upload_test.js index eff106e5..f7d9b291 100644 --- a/test/upload_test.js +++ b/test/upload_test.js @@ -94,7 +94,10 @@ describe('S3 Webpack Upload', function() { BASE_PATH = 'test' var s3Config = { basePath: BASE_PATH, - basePathTransform(basePath) { + basePathTransform(basePath, compilation) { + assert.isString(basePath); + assert.isObject(compilation); + return Promise.resolve(basePath + NAME_PREFIX) } } @@ -117,7 +120,10 @@ describe('S3 Webpack Upload', function() { BASE_PATH = 'test' var s3Config = { basePath: BASE_PATH, - basePathTransform(basePath) { + basePathTransform(basePath, compilation) { + assert.isString(basePath); + assert.isObject(compilation); + return basePath + NAME_PREFIX } }