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

Pass mimeTypes option to webpack-dev-middleware #1714

Merged
merged 5 commits into from
Apr 4, 2019

Conversation

dmohns
Copy link
Contributor

@dmohns dmohns commented Mar 10, 2019

  • This is a bugfix
  • This is a feature
  • This is a code refactor
  • This is a test update
  • This is a docs update
  • This is a metadata update

For Bugs and Features; did you add new tests?

Yes, tests for createConfig, a basic sanity check and test for changed mime type.

Motivation / Use-Case

webpack-dev-middleware exposes an option to set custom mime types via
passing a mimeType object, see
https://github.com/webpack/webpack-dev-middleware#mimetypes

This commit allows the user to set devServer.mimeType in
webpack.config.js to pass custom mimes types to
webpack-dev-middleware

Closes #1700

Breaking Changes

No.

Additional Info

As part of this change the documentation at https://webpack.js.org/guides/development/ needs to be updated as well. I couldn't yet figure out how this is done. And, whether or not the documentation has to be updated at the time (or can be updated later, once this PR is merged).

ToDo

`webpack-dev-middleware` exposes an option to set custom mime types via 
passing a mimeType object, see 
https://github.com/webpack/webpack-dev-middleware#mimetypes

This commit allows the user to set `devServer.mimeType` in 
`webpack.config.js` to pass custom mimes types to 
`webpack-dev-middleware`
@dmohns dmohns force-pushed the feature/custom-mimetype-option branch from a4203c9 to f811ae3 Compare March 10, 2019 19:45
@codecov
Copy link

codecov bot commented Mar 10, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@05b8fb7). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1714   +/-   ##
=========================================
  Coverage          ?   83.76%           
=========================================
  Files             ?        8           
  Lines             ?      536           
  Branches          ?      161           
=========================================
  Hits              ?      449           
  Misses            ?       70           
  Partials          ?       17

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 05b8fb7...f65705a. Read the comment docs.

@dmohns dmohns force-pushed the feature/custom-mimetype-option branch from f811ae3 to c780289 Compare March 10, 2019 19:50
@alexander-akait
Copy link
Member

We create new issue in documentation page after merge, please ping me when we can review your PR, anyway code looks good, thanks!

@dmohns dmohns changed the title [WIP] Pass mimeTypes option to webpack-dev-middleware Pass mimeTypes option to webpack-dev-middleware Mar 11, 2019
@dmohns
Copy link
Contributor Author

dmohns commented Mar 11, 2019

@evilebottnawi this PR can be reviewed. I updated the description to mirror the changes from the latest commits.

One question: In the test, I need to request main.js for the test to work, while it looks like other tests use bundle.js. Is this correct?

@alexander-akait
Copy link
Member

alexander-akait commented Mar 11, 2019

One question: In the test, I need to request main.js for the test to work, while it looks like other tests use bundle.js. Is this correct?

Good question, we need check what is file created after run build

Anyway code looks good, let's investigate about main.js and bundle.js and we can merge

@dmohns
Copy link
Contributor Author

dmohns commented Mar 11, 2019

It seems the default naming (when no output.filename is given) is not really documented anywhere. But this comment webpack/webpack#6543 (comment) suggests that the output filename will simply be the chunk name. While the chunk name again will be main because we are not using named (dict) entries but unnamed.

@alexander-akait
Copy link
Member

@dmohns yep, let's look what file exists in output path for our test config (it should be simple)

@dmohns
Copy link
Contributor Author

dmohns commented Mar 14, 2019

I am a little lost on this one. From the code, it simply looks like filename is not set (only path), see

@alexander-akait
Copy link
Member

/cc @hiroppy can you see in test and help, don't have time right now

@alexander-akait
Copy link
Member

@dmohns also please rebase on master

@alexander-akait
Copy link
Member

/cc @hiroppy

Copy link
Member

@hiroppy hiroppy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks!

@hiroppy hiroppy merged commit abf8691 into webpack:master Apr 4, 2019
@hiroppy
Copy link
Member

hiroppy commented Apr 4, 2019

@dmohns Could you submit a pr about this to https://github.com/webpack/webpack.js.org?

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.

Pass mimeTypes options to webpack-dev-middleware
4 participants