static-dev / spike-core

:warning: UNMAINTAINED :warning: A modern static build tool, powered by webpack
https://spike.js.org
Other
58 stars 9 forks source link

Using SpikeWebpackPlugin with other webpack configs #242

Closed svicalifornia closed 6 years ago

svicalifornia commented 7 years ago

I'd like to use SpikeWebpackPlugin with other webpack configs (such as create-react-app, create-inferno-app, and other custom configs with hot-reload and ESLint support). I considered trying to add webpack-hot-middleware to Spike's webpack config (via app.js), but couldn't figure out how to configure the opts.server property that gets passed into the BrowserSync configuration.

So instead, I'm now attempting to reuse the SpikeWebpackPlugin from spike-core in my webpack configs, which I can import like this:

import SpikeWebpackPlugin from 'spike-core/lib/plugin';

But I'm curious if the plug-in is sufficiently and reliably stable enough to use it directly like this. Since it is part of spike-core and not its own module, perhaps you consider it to be encapsulated and subject to major changes that would disrupt its independent usage. Please advise?

svicalifornia commented 7 years ago

I see that SpikeWebpackPlugin requires spike-utils, a module which in turn notes in its comments that it should be merged back into spike-core. Would you like a pull request to do that? Are any other packages using spike-utils?

svicalifornia commented 7 years ago

I guess if I were to summarize the separate points raised in this issue, it seems that there are multi-directional couplings between spike's Config, SpikeUtil, and SpikeWebpackPlugin, which make it difficult to use these parts (especially SpikeWebpackPlugin) independently. It also seems somewhat tricky to modify any of these three parts without potentially causing problems across the separate modules of spike, spike-core, and spike-util, and it seems that one would have to run tests in all three modules to validate changes. It would be great if these were more decoupled. Would you be interested in help with that?

jescalan commented 7 years ago

Hey Shawn,

Wow, thanks for digging in so deep on this. So, the core logic pieces of spike are not intended to be used independently, which is why they are not packaged independently or documented for independent use. It would be exceedingly difficult to make this happen, and would be much, much easier to just add a hot reloading option to spike.

If you'd like to talk about adding the hot reloading feature, I would be happy to chat about this. Basically, it would involve adding webpack dev middleware with a proxy to browsersync, then slotting in an option to toggle it. The only reason I haven't added it yet is because the time difference is so minimal and I haven't had the need for it vs. other features I'm working on like i18n. But if you'd be willing to help, it would do a lot as far as pushing this forward!

jescalan commented 6 years ago

Closing due to inactivity