webpack-contrib / purifycss-webpack

UNMAINTAINED, use https://github.com/FullHuman/purgecss-webpack-plugin
MIT License
772 stars 37 forks source link

Purify by chunk feature #51

Closed nenadpnc closed 7 years ago

nenadpnc commented 8 years ago

As is stands right now, plugin assumes that there is only one entry point in webpack configuration. In that case, plugin will extract all provided html files, plus all dependencies and pass it to purify function.

Problem occurs, when there are multiple entry points, so there are separate bundles of js and css code. We don't want to provide all html and dependencies files to purify function, just files that are tied to specific chunk.

My suggestion is, if there are multiple chunks, execute purify for every chunk with files that are tied to that specific chunk. User has to specifies html entry paths for each chunk. So, if we have configuration for entry like this: entry: { a: "./a", b: "./b", c: ["./c", "./d"] }, Configuration for plugin would look like this: plugins: [ new purify({ basePath: __dirname, entryPaths: { a: ["app/views/a/*.html"], b: ["app/views/b/*.html"], c: ["app/views/c/*.html"] } }) ]

Plugin will execute purify in standard way if either one of this configuration is provided:

bebraw commented 7 years ago

Hi,

I have a friendly fork going on here. I pretty much redid the internals, but it would still be cool to port this work over there if you are still interested.

Instead of entryPaths I would piggyback on paths. I've also pushed globbing outside of the plugin (more versatile).

bebraw commented 7 years ago

I merged this manually earlier (we moved the repo). That's why this got closed. I think we still may want to revisit the topic, though.

bebraw commented 7 years ago

@nenadpnc I integrated the ideas to the master version. I still need to add some tests etc. but after that it's good to go once I get npm release rights from @IngwiePhoenix.