-
Notifications
You must be signed in to change notification settings - Fork 512
Conversation
lcxfs1991
commented
Feb 21, 2017
- Read and sign the CLA. This needs to be done only once. PRs that haven't signed it won't be accepted.
- Check out the development guide for the API and development guidelines.
- Read through the PR diff carefully as sometimes this can reveal issues. The work will be reviewed, but this can save some effort.
- Remove these instructions from your PR as they are for your eyes only.
Codecov Report
@@ Coverage Diff @@
## master #423 +/- ##
==========================================
+ Coverage 90.25% 90.38% +0.13%
==========================================
Files 6 6
Lines 359 364 +5
Branches 75 76 +1
==========================================
+ Hits 324 329 +5
Misses 35 35
Continue to review full report at Codecov.
|
README.md
Outdated
@@ -155,6 +155,29 @@ module.exports = { | |||
} | |||
``` | |||
|
|||
### Modify filename | |||
|
|||
`filename` paramter could be `Object`. It accepts `format` and `modify` callback as attributes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/s/paramter/parameter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does that mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a typo.
README.md
Outdated
@@ -68,7 +68,7 @@ new ExtractTextPlugin(options: filename | object) | |||
|Name|Type|Description| | |||
|:--:|:--:|:----------| | |||
|**`id`**|`{String}`|Unique ident for this plugin instance. (For advanced usage only, by default automatically generated)| | |||
|**`filename`**|`{String}`|Name of the result file. May contain `[name]`, `[id]` and `[contenthash]`| | |||
|**`filename`**|`{String|Object}`|Name of the result file. May contain `[name]`, `[id]` and `[contenthash]`| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could accept a function directly instead of an object. The function would return a filename and allow you modify it. Simpler API/design.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also have to pass filename format like [name].css
. Is is possible to do that via a function
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can return a pattern and it will work like before. You can do filename: file => '[name].css'
in this design too. And access to the file
parameter gives you flexibility for custom logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you add js/a
as the entry key, webpack will replace [name]
with css/js/a
and it leaves no room for developers to do the following action:
filename.replace('js/css', 'css');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can try my test case:
test/cases/multiple-entries-filename/webpack.config.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. It's that compilation.getPath
which is the problem. Basically modify
triggers after that.
The design could be inverted like this:
filename: (getPath, filename) => getPath(filename)
That getPath
would run compilation.getPath
with all its parameters and provide the hook that would give you maximum amount of control. Now you could manipulate filename
before and after placeholders get applied while keeping the API surface minimal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expose getPath
is cool too.
let me retune it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'll have a closer look in a bit. 👍
This looks good to me. Please resolve that conflict (had to merge a readme fix). I'll merge this for 2.1 (first release after final 2.0). |
@d3viant0ne Do you want to take a quick peek? Looks good to me for a quick 2.1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @lcxfs1991 - Ship it :)
Published as |