At the moment, spike-core's plugin will determine the output path of every file by running the source path through a basic transform that will essentially nest it into public and correct its extension if necessary. However, in some cases, users might want to write a file to a different location or under a different name to the output, and this should be achievable through spike plugins.
Right now, changing f.path directly will cause errors, since this represents the source path, which is also used to get the source from webpack before writing. It seems to me like the best way to pull this off would be to allow another f.outPath property to be added which would be used if present. The only other way to accomplish something similar would be to add a custom loader just to get the files you need, and add skipSpikeProcessing to that loader, then manually replicate the spike core static plugin process for writing files, which seems like an inferior approach.
Since neither method is smooth, however, I think adding a spike-util method to change a given file's output path would be a fantastic utility after this feature is added.
At the moment, spike-core's plugin will determine the output path of every file by running the source path through a basic transform that will essentially nest it into
public
and correct its extension if necessary. However, in some cases, users might want to write a file to a different location or under a different name to the output, and this should be achievable through spike plugins.This is the spot where it could happen: https://github.com/static-dev/spike-core/blob/master/lib/plugin.js#L69
Right now, changing
f.path
directly will cause errors, since this represents the source path, which is also used to get the source from webpack before writing. It seems to me like the best way to pull this off would be to allow anotherf.outPath
property to be added which would be used if present. The only other way to accomplish something similar would be to add a custom loader just to get the files you need, and addskipSpikeProcessing
to that loader, then manually replicate the spike core static plugin process for writing files, which seems like an inferior approach.Since neither method is smooth, however, I think adding a
spike-util
method to change a given file's output path would be a fantastic utility after this feature is added.