skpm: Adding 'plugins' to user-defined webpack config produces incorrect build output for commands
Looking through skpm
sources I figured out that I can use my own webpack.config.js
to augment included skpm’s webpack config.
I was playing around this feature and stumbled upon pretty weird case when I add custom plugins
into webpack config.
Though build finishes successfully and my plugins are applied, output command scripts appear wrapped multiple times into run
function (by WebpackHeaderFooterPlugin
), moreover commands from different “script” are included (I have multiple "script"s defined in “manifest.json”). If you try to run it from Sketch, it will crash with an exception: Exception: TypeError: undefined is not an object (evaluating that.context = context)
.
I guess that’s caused by the following in webpackConfig.js
:
https://github.com/skpm/skpm/blob/791429d0965f76a4c20cdf7ce15625c1efb803e5/lib/utils/webpackConfig.js#L166
My guess is that when multiple “script” files are run through ‘webpack’ userDefinedWebpackConfig.plugins
becomes mutated.
Changing it to let plugins = [...userDefinedWebpackConfig.plugins] || []
did indeed fixed that.
I can provide a PR that introduces exactly that change, or can provide with repro case for you to look around.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 17 (17 by maintainers)
Just pushed template for
skpm
with TypeScript and TSLint here: https://github.com/romansp/skpm-typescript. That was really easy to do. Thanks a lot for your efforts adding support for custom templates andskpm
in general. 👍