cdn-upload-webpack-plugin
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -23,5 +23,8 @@ /// <reference types="webpack" /> | ||
export default class AzurePlugin implements Plugin { | ||
private options; | ||
private blobService; | ||
private upload; | ||
constructor(options: IAzureOptions); | ||
apply(compiler: Compiler): void; | ||
getPublicPath(): string; | ||
} |
@@ -24,2 +24,12 @@ "use strict"; | ||
} | ||
function connectBlobService(options) { | ||
// Connect to Azure using one of the provided connection methods | ||
if (options.connection && isConnectionString(options.connection)) { | ||
return AzureStorage.createBlobService(options.connection.connectionString); | ||
} | ||
if (options.connection && isAccountAndKey(options.connection)) { | ||
return AzureStorage.createBlobService(options.connection.storageAccount, options.connection.storageAccessKey, options.connection.host); | ||
} | ||
return AzureStorage.createBlobService(); | ||
} | ||
var StatusType; | ||
@@ -99,14 +109,3 @@ (function (StatusType) { | ||
*/ | ||
function createAzureUpload(options) { | ||
// Connect to Azure using one of the provided connection methods | ||
var blobService; | ||
if (options.connection && isConnectionString(options.connection)) { | ||
blobService = AzureStorage.createBlobService(options.connection.connectionString); | ||
} | ||
else if (options.connection && isAccountAndKey(options.connection)) { | ||
blobService = AzureStorage.createBlobService(options.connection.storageAccount, options.connection.storageAccessKey, options.connection.host); | ||
} | ||
else { | ||
blobService = AzureStorage.createBlobService(); | ||
} | ||
function createAzureUpload(blobService, options) { | ||
/* | ||
@@ -271,3 +270,5 @@ * Created transformed BlobService methods which return an Observable instead of taking a callback. | ||
function AzurePlugin(options) { | ||
this.upload = createAzureUpload(options); | ||
this.options = options; | ||
this.blobService = connectBlobService(options); | ||
this.upload = createAzureUpload(this.blobService, options); | ||
} | ||
@@ -312,4 +313,7 @@ AzurePlugin.prototype.apply = function (compiler) { | ||
}; | ||
AzurePlugin.prototype.getPublicPath = function () { | ||
return this.blobService.getUrl(this.options.containerName, this.options.prefix); | ||
}; | ||
return AzurePlugin; | ||
}()); | ||
exports.default = AzurePlugin; |
{ | ||
"name": "cdn-upload-webpack-plugin", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "A webpack plugin which incrementally uploads assets to a CDN upon build completion", | ||
@@ -26,2 +26,3 @@ "main": "./lib/index.js", | ||
"@types/webpack": "^4.1.4", | ||
"html-webpack-plugin": "^3.2.0", | ||
"lodash": "^4.17.4", | ||
@@ -28,0 +29,0 @@ "prettier": "1.12.1", |
@@ -25,26 +25,30 @@ # cdn-upload-webpack-plugin | ||
const azureUploadPlugin = new CdnUploadPlugin.Azure({ | ||
// Leave `connection` undefined to use environment variables | ||
// AZURE_STORAGE_CONNECTION_STRING / AZURE_STORAGE_ACCOUNT / AZURE_STORAGE_ACCESS_KEY | ||
// i.e. http://azure.github.io/azure-storage-node/global.html#createBlobService__anchor | ||
// Or define as: | ||
connection: { | ||
connectionString: '<your connection string>' | ||
}, | ||
// or | ||
connection: { | ||
storageAccount: '<your storage account>', | ||
storageAccessKey: '<your access key>' | ||
}, | ||
// The name of the container on Azure, which will be created if it doesn't exist | ||
containerName: 'files', | ||
// The filename prefix to be used for all uploaded assets | ||
prefix: 'my/test/folder' | ||
}); | ||
module.exports = { | ||
entry: './index.js', | ||
output: { | ||
filename: 'bundle.js' | ||
filename: 'bundle.js', | ||
// Set your publicPath to have chunks loaded via the CDN: | ||
publicPath: azureUploadPlugin.getPublicPath() | ||
}, | ||
plugins: [ | ||
new CdnUploadPlugin.Azure({ | ||
// Leave `connection` undefined to use environment variables | ||
// AZURE_STORAGE_CONNECTION_STRING / AZURE_STORAGE_ACCOUNT / AZURE_STORAGE_ACCESS_KEY | ||
// i.e. http://azure.github.io/azure-storage-node/global.html#createBlobService__anchor | ||
// Or define as: | ||
connection: { | ||
connectionString: '<your connection string>' | ||
}, | ||
// or | ||
connection: { | ||
storageAccount: '<your storage account>', | ||
storageAccessKey: '<your access key>' | ||
}, | ||
// The name of the container on Azure, which will be created if it doesn't exist | ||
containerName: 'files', | ||
// The filename prefix to be used for all uploaded assets | ||
prefix: 'my/test/folder' | ||
}) | ||
azureUploadPlugin | ||
] | ||
@@ -51,0 +55,0 @@ }; |
@@ -60,2 +60,17 @@ import * as AzureStorage from 'azure-storage'; | ||
function connectBlobService(options: IAzureOptions) { | ||
// Connect to Azure using one of the provided connection methods | ||
if (options.connection && isConnectionString(options.connection)) { | ||
return AzureStorage.createBlobService(options.connection.connectionString); | ||
} | ||
if (options.connection && isAccountAndKey(options.connection)) { | ||
return AzureStorage.createBlobService( | ||
options.connection.storageAccount, | ||
options.connection.storageAccessKey, | ||
options.connection.host, | ||
); | ||
} | ||
return AzureStorage.createBlobService(); | ||
} | ||
interface IAsset { | ||
@@ -240,18 +255,5 @@ emitted: boolean; | ||
function createAzureUpload( | ||
blobService: AzureStorage.BlobService, | ||
options: IAzureOptions, | ||
): (assets: { [assetName: string]: IAsset }) => Rx.Observable<Status> { | ||
// Connect to Azure using one of the provided connection methods | ||
let blobService; | ||
if (options.connection && isConnectionString(options.connection)) { | ||
blobService = AzureStorage.createBlobService(options.connection.connectionString); | ||
} else if (options.connection && isAccountAndKey(options.connection)) { | ||
blobService = AzureStorage.createBlobService( | ||
options.connection.storageAccount, | ||
options.connection.storageAccessKey, | ||
options.connection.host, | ||
); | ||
} else { | ||
blobService = AzureStorage.createBlobService(); | ||
} | ||
/* | ||
@@ -516,6 +518,10 @@ * Created transformed BlobService methods which return an Observable instead of taking a callback. | ||
export default class AzurePlugin implements Plugin { | ||
private options: IAzureOptions; | ||
private blobService: AzureStorage.BlobService; | ||
private upload: (assets: { [assetName: string]: IAsset }) => Rx.Observable<Status>; | ||
constructor(options: IAzureOptions) { | ||
this.upload = createAzureUpload(options); | ||
this.options = options; | ||
this.blobService = connectBlobService(options); | ||
this.upload = createAzureUpload(this.blobService, options); | ||
} | ||
@@ -567,2 +573,6 @@ | ||
} | ||
public getPublicPath() { | ||
return this.blobService.getUrl(this.options.containerName, this.options.prefix); | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
39370
888
67
0
10