Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support CDNs #11

Closed
chmontgomery opened this issue Aug 4, 2014 · 2 comments
Closed

support CDNs #11

chmontgomery opened this issue Aug 4, 2014 · 2 comments
Milestone

Comments

@chmontgomery
Copy link
Contributor

detect cdn urls and, if present, don't bundle anything but instead add it to the bundle.results.json as a scripts/style include from the given url

@chmontgomery chmontgomery added this to the 3.0 milestone Aug 4, 2014
@chmontgomery chmontgomery modified the milestones: 3.x, Ice Box Aug 4, 2014
@timelf123
Copy link

Can you give an example of how this would work?

I originally misread the title as being able to push your built files to a CDN. For those looking to do that, here is an easy way to do it with gulp-cloudfront and gulp-awspublish.

var gulp = require('gulp');
var cloudfront = require('gulp-cloudfront');
var awspublish = require('gulp-awspublish');

// AWS config object
var aws = {
  'params': {
    'Bucket': 'bucketname' // s3 bucket
  },
  'accessKeyId': 'yourAccessKeyId',
  'secretAccessKey': 'yourSecretAccessKey',
  'distributionId': 'yourCloudFrontDistributionId' 
};

var publisher = awspublish.create(aws);
var headers = {'Cache-Control': 'max-age=315360000, no-transform, public'};

/**
 * ITS CDN TIME
 */
gulp.task('cdn', function () {
    gulp.src('public/distribution/**')
        .pipe(awspublish.gzip())
        .pipe(publisher.publish(headers))
        .pipe(publisher.cache())
        .pipe(awspublish.reporter())
        .pipe(cloudfront(aws));
});

@chmontgomery
Copy link
Contributor Author

@timelf123 right, this issue is not about pushing built files to a CDN. There are plenty of other good plugins already for that.

This is meant for the bundle.result.json file, i.e. the generated result could look like this:

{
  "main": {
    "scripts": "<script src='//abc.akamai.net/main.js' type='text/jsx'></script>",
    "styles": "<link href='//abc.akamai.net/main.css' media='all' rel='stylesheet' type='text/css'/>"
  },
  "vendor": {
    "scripts": "<script src='//abc.akamai.net/vendor.js' type='text/javascript'></script>"
  }
}

Since this issue was written we added support for the bundle.result pathPrefex option. If that doesn't support your use case, we have a different issue open for a pathPrefix per bundle: #60

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants