momocow / webpack-userscript

A Webpack plugin for userscript projects. 🙈
https://cow.moe/webpack-userscript/
MIT License
202 stars 21 forks source link

How to use this plugin only for certain webpack entries? #36

Closed Buntelrus closed 1 year ago

Buntelrus commented 4 years ago

I have a userscript with pdf.js as a dependency. And for that I need an extra entry for a worker file.

entry: {
    main: "./app/index.js",
    "pdf.worker": "pdfjs-dist/build/pdf.worker.entry",
  }

If I build the project, I get 2 files:

main.bundle.user.js
pdf.worker.bundle.user.js`

But what I want is 1 user script main.bundle.user.js and 1 normal bundle pdf.worker.bundle.js. Is this possible? How can I do this?

momocow commented 4 years ago

You can try to build those files via multiple configuration objects with different plugins supplied.

https://webpack.js.org/configuration/configuration-types/#exporting-multiple-configurations

Buntelrus commented 4 years ago

thanks for the answer. I will try that :)

momocow commented 4 years ago

I'll close this issue now but feel free to reopen it if there is further question.

iamogbz commented 4 years ago

@momocow how would I get this to work with code splitting? Currently all my chunks get appended with .user.jsand the userscript headers when I only want it for the specified entries. Use case is sharing library code between entry userscripts.

momocow commented 4 years ago

@iamogbz I've created a new issue #41 for discussion. Maybe provide a simplified concrete example for me to better understand your requirements.

momocow commented 3 years ago

I'll reopen this issue since there are some changes in the incoming v3 which can improve the solution of this issue.

inazuma-bot commented 1 year ago

:tada: This issue has been resolved in version 3.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: