Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cdn-upload-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cdn-upload-webpack-plugin - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

3

lib/storage/azure.d.ts

@@ -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;
}

30

lib/storage/azure.js

@@ -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);
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc