Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] allow copy files before and after webpack build #195

Open
factoidforrest opened this issue Dec 18, 2017 · 8 comments
Open

[Feature] allow copy files before and after webpack build #195

factoidforrest opened this issue Dec 18, 2017 · 8 comments

Comments

@factoidforrest
Copy link

My entry point is inside the directory that has been copied. This plugin seems to use the webpack file emit at the end to output the files. Is there a way to do this sooner? Or to somehow target an entrypoint inside the copied directory?

@michael-ciniawsky
Copy link
Member

cp src/* dist/* && webpack

Sry, this plugin is an integration of cp for webpack during runs, there is no way to start/use a webpack plugin without actually starting webpack

@factoidforrest
Copy link
Author

factoidforrest commented Dec 18, 2017

But you could hook into the compilation process before entrypoints are resolved. I ended up doing it like this:

const EventHooksPlugin = require('event-hooks-webpack-plugin');
const fs = require('fs-extra')

//in webpack plugins
      new EventHooksPlugin({
        'before-run': (compilation, done) => {
          console.log('Copying source files to compiled')
          fs.copy('src', 'compiled', done);
        }
      }),

@michael-ciniawsky
Copy link
Member

Sry, I overread entrypoints :), (maybe) possible, but not supported atm

@stereokai
Copy link

@light24bulbs Thank you, your comment helped out a lot!

@alexander-akait alexander-akait changed the title Is there a way to make the copy happen before webpack loads the entry points? [Feature] allow copy files before and after webpack build Feb 18, 2019
@alexander-akait alexander-akait removed this from the 4.6.0 milestone Feb 18, 2019
@appsparkler
Copy link

@evilebottnawi

It would be nice to have an option like event (either in options or pattern config) which will decide when the copy is executed.

@alexander-akait
Copy link
Member

PR welcome

@rburnham52

This comment has been minimized.

@Qvatra
Copy link

Qvatra commented Jun 28, 2021

possible workaround is to use WebpackShellPlugin
https://stackoverflow.com/questions/36773619/webpack-execute-function-before-build-starts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants