Closed momocow closed 1 year ago
Splitting imports in the userscript to different chunks results in the chunks also suffixed with .user.js
not only the entry files.
// webpack.config.js
export default {
entry: "./scripts",
optimization: {
splitChunks: {
chunks: "all",
cacheGroups: {
lib: {
test: /[\\/]libraries[\\/](.*?)\.ts$/,
name(module) {/* return lib chunk name */},
},
},
},
/* ... */
}
The use case for this is publishing shared library files that multiple userscripts can point to import. It would useful to be able to decide what files get affected by the plugin.
I was able to get around this by having two different config files, one for compiling and optimizing and another with the WebpackUserscript
plugin for creating the .user.js
files. I guess I'm doing some other weird things as being able to specify different header object for each script was needed as well. See oh-my-scripts/webpack.config.ts
.
Splitting imports in the userscript to different chunks results in the chunks also suffixed with .user.js not only the entry files.
I got your point.
Currently all .js
files in an entry chunk are packed into .user.js
files respectively. In a simple use case, there is usually only one file in a chunk.
It seems that only packing the entry file into an .user.js
file can satisfy your use case, am I right?
That would work! Although there's still the use case of being able to specify different header objects for different user scripts.
@iamogbz Headers can be specified with a header provider function, which is called before each time a file is packed into an .user.js
.
Hope this can meet your requirement, or let me know the detailed use case!
:tada: This issue has been resolved in version 3.0.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket: