Skip to content

Commit 41c7bbe

Browse files
committed
Merge pull request #2 from jamesdixon/master
fixes support for gzip
2 parents b05c379 + 6b4c9b1 commit 41c7bbe

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,12 @@ module.exports = function(environment) {
3030
}
3131
```
3232

33+
### Connection String
3334
You can also connect using your connection string, set it as `connectionString: "my-connection-string"`.
34-
It's possible to gzip assets, but it leads to strange results (https://github.com/duizendnegen/ember-cli-deploy-azure/issues/6).
35+
36+
### Gzip Support
37+
If you're using [ember-cli-deploy-gzip](https://github.com/ember-cli-deploy/ember-cli-deploy-gzip) to automatically compress your assets using gzip, this plugin will automatically detect files that have been gzipped and set the proper `Content-Encoding` header within Azure Blob Storage.
38+
3539

3640
## Usage
3741

index.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ module.exports = {
1717
name: options.name,
1818

1919
defaultConfig: {
20-
containerName: 'emberdeploy',
21-
gzipExtensions: ['js', 'css', 'svg'],
22-
gzip: false
20+
containerName: 'emberdeploy'
2321
},
2422

2523
_createClient: function() {
@@ -45,6 +43,7 @@ module.exports = {
4543
},
4644

4745
upload: function(context) {
46+
4847
var client = this._createClient();
4948
var _this = this;
5049

@@ -76,7 +75,8 @@ module.exports = {
7675
var walker = walk.walk(distDir, { followLinks: false });
7776

7877
walker.on("file", function (root, fileStats, next) {
79-
_this._uploadFile(root, fileStats, next, context.distDir, client);
78+
var gzippedFiles = context.gzippedFiles || [];
79+
_this._uploadFile(root, fileStats, next, context.distDir, client, gzippedFiles);
8080
});
8181

8282
walker.on("errors", function(root, nodeStatsArray, next) {
@@ -101,7 +101,7 @@ module.exports = {
101101
});
102102
});
103103
},
104-
_uploadFile: function(root, fileStat, next, distDir, client) {
104+
_uploadFile: function(root, fileStat, next, distDir, client, gzippedFiles) {
105105
var _this = this;
106106

107107
var containerName = this.readConfig("containerName");
@@ -113,12 +113,7 @@ module.exports = {
113113

114114
var options = {}
115115

116-
var extname = path.extname(resolvedFile).replace('.');
117-
var gzipExtensions = this.readConfig("gzipExtensions");
118-
var hasBeenGziped = gzipExtensions.indexOf(extname) !== -1;
119-
var gzipEnabled = this.readConfig("gzip");
120-
121-
if(gzipEnabled && hasBeenGziped) {
116+
if (gzippedFiles.indexOf(targetFile) != -1) {
122117
options["contentEncoding"] = "gzip";
123118
}
124119

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ember-cli-deploy-azure-blob",
3-
"version": "0.1.1",
3+
"version": "0.2.0",
44
"description": "Deploy assets from Ember App to Azure Blob using ember-cli-deploy.",
55
"directories": {
66
"doc": "doc",

0 commit comments

Comments
 (0)