mrbar42 / ignore-emit-webpack-plugin

Prevents ignored files from being emitted during a Webpack build
MIT License
18 stars 1 forks source link

Avoid to inject ignored JS files inside templates #24

Closed thewebartisan7 closed 11 months ago

thewebartisan7 commented 2 years ago

The ignored JS files are not compiled, but are injected inside html template. It's possible to avoid this?

Thanks

mrbar42 commented 2 years ago

Can you share your webpack config? i would assume there is a plugin that is responsible for the html injection part.

thewebartisan7 commented 2 years ago

Actually it's a bit long and even splitted dev and prod.

However I suppose it's HtmlWebpackPlugin that is injecting the scripts and css that you are asking for. Right?

thewebartisan7 commented 2 years ago

One thing, this happen with webpack 4.x

I have recently upgrade to webpack 5.x and I am doing test right now.

Seem that it's doesn't happen with webpack 5.x

mrbar42 commented 2 years ago

that make sense actually, because in Webpack v4 and earlier ignoring an asset is somewhat hacky while in v5 there is an explicit method to do that which probably cleans the asset properly and doesn't leave traces that can later get picked up by other plugins.

thewebartisan7 commented 2 years ago

Yes I know that it's hacky in v4, and I saw you are using method deleteAsset. I thought the same thing when I see.

There are some workaround for v4 that I try, but none worked.