erikdesjardins / zip-webpack-plugin

Webpack plugin to zip up emitted files.
https://www.npmjs.com/package/zip-webpack-plugin
MIT License
106 stars 22 forks source link

Including things outside the Webpack output path #26

Closed poltak closed 6 years ago

poltak commented 6 years ago

Hi there. Apologies if this is simple; I can't seem to find out how to do it from reading the docs/previous issues.

I have a working plugin instance producing a zip of my built files (in proj/extension/ subdir - webpack's output), but I also want to set up another plugin instance to produce a zip of the source files (in proj/src/ subdir).

I've tried things like setting the include option to a string like '../src/**/*' and '../src/' however this results in an empty zip. Is there a way to include files outside the webpack output dir?


For reference, my working plugin that zips the built assets looks like this:

new ZipPlugin({
  path: '../dist',
  filename: 'extension.zip',
  exclude: [/\.map/],
})

This project is a Chrome and FF compatible web extension and Mozilla requires us to send zipped-up source code as part of the FF add-on submission for later review. Worst-case I'll just automate it outside of the scope of webpack, but would be nice to do all needed packaging together (and I'm probably just missing something small).

Thanks for taking the time to read.

erikdesjardins commented 6 years ago

Right now loading files from outside the webpack build/emit process is out of scope for this plugin, so you have a few options:

My main concern with adding it is: right now this plugin is relatively simple, because webpack handles the file loading, dependency tracking for watch mode, etc., and this plugin just reads the assets; but to load additional files that has to be done manually (see, e.g., copy-webpack-plugin source).

Incidentally, I also contribute to a browser extension (honestbleeps/Reddit-Enhancement-Suite), but we don't submit the source code to Mozilla. I believe we link to the repo instead.

poltak commented 6 years ago

Thanks for your detailed reply and suggestions @erikdesjardins! First one seems to be the simplest for now, so I found the very simple post-compile-webpack-plugin which affords running a custom callback in which I can just do a child_process.exec call to zip things manually for now.

Incidentally, I also contribute to a browser extension (honestbleeps/Reddit-Enhancement-Suite), but we don't submit the source code to Mozilla. I believe we link to the repo instead.

It would be great to not have to worry about this and just send a link. I don't handle submissions, but I'll have a talk to the guy who does :) Thanks for the heads-up!