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

Add support for customizing publicPath #9

Merged
merged 1 commit into from
Mar 27, 2018

Conversation

pcardune
Copy link
Contributor

Since image assets can take up quite a lot of bandwidth and storage space, it's nice to be able to have them served directly from a cloud storage service like S3.

In this PR I've added a new configuration option, imagesPublicPath, which allows you to customize the url generated by file-loader. For example, if you were using google cloud storage:

const optimizedImages = require('next-optimized-images');

let imagesPublicPath;
if (process.env.NODE_ENV === 'production') {
  imagesPublicPath = "https://storage.googleapis.com/my-bucket/images";
}

module.exports = optimizedImages({imagesPublicPath})({
  //...next config here
});

Then after building your application, you would sync the images to google cloud storage:

next build
gsutil -m rsync -r .next/dist/static/images gs://my-bucket/images

@codecov
Copy link

codecov bot commented Mar 27, 2018

Codecov Report

Merging #9 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master     #9   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           1      1           
  Lines          42     42           
  Branches       13     13           
=====================================
  Hits           42     42
Impacted Files Coverage Δ
index.js 100% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aacb5f1...4c95180. Read the comment docs.

@cyrilwanner
Copy link
Owner

Cool, this is really useful 👍
Thank you very much for the contribution @pcardune :)

@cyrilwanner cyrilwanner merged commit 00b9d71 into cyrilwanner:master Mar 27, 2018
@cyrilwanner
Copy link
Owner

This improvement has been published to npm with version 1.2.2

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

Successfully merging this pull request may close these issues.

2 participants