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 option for default sizes & setting output context #12

Merged
merged 3 commits into from
Aug 20, 2016

Conversation

alex-ketch
Copy link
Collaborator

@alex-ketch alex-ketch commented Aug 16, 2016

Thanks for creating this loader. Let me know if you’d be open to the following PR.

This PR adds ability to declare a default Sizes array in webpack.config.js, and uses those sizes in case neither sizes nor size are declared in the query.

Default name, context, quality, and background options can now also be defined.


Additionally this interprets the context variable, if present in the query or settings.
This allows flexibility when outputting files.

For example my Webpack project structure is like this:

|-- app <-- source files
|----assets
|------images
|--------someFile.jpg
|-- dist <-- webpack output destination

Now I can structure my query to be loader: 'responsive?name=/[path][name][hash]-[width].&context=./app/' to output files to dist while keeping the rest of the nested folder structure from app/assets.

|-- app <-- source files
|----assets
|------images
|--------someFile.jpg
|-- dist <-- webpack output destination
|----assets
|------images
|--------someFile[someHash]-[width].jpg

@jstcki
Copy link
Contributor

jstcki commented Aug 19, 2016

Nice! I didn't know about context but apparently file-loader uses it too. Do you want to include #13 in this PR too?

@alex-ketch
Copy link
Collaborator Author

alex-ketch commented Aug 19, 2016

Yeah, I think context is very poorly documented—if it is at all. Came across it by accident while trying to tidy up the output folder structure.

As for #13, most likely it will be a few days before I can get to it it. So maybe it's better I make a separate PR for that?

Thanks again for taking a look at this

@jstcki jstcki merged commit 9497ba7 into dazuaz:master Aug 20, 2016
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