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

[Discussion] Plugin goals #60

Closed
chrisblossom opened this issue Jun 13, 2017 · 6 comments
Closed

[Discussion] Plugin goals #60

chrisblossom opened this issue Jun 13, 2017 · 6 comments

Comments

@chrisblossom
Copy link
Collaborator

@johnagan I think a lot of issues people have are created because there is confusion when/why to use this plugin.

A webpack plugin to remove your build folder(s) before building

Is this plugin meant to clean the build only once before the first webpack build? Is the goal clean project files before every compilation?

I personally do not see much value in a webpack plugin that cleans a project once before the build. I think it makes webpack more complicated/error prone, and is better solved with existing solutions and build tools.

Here is an extremely simple example how to integrate a clean directly with a webpack config without a plugin:

import webpack from 'webpack';
import path from 'path';
import del from 'del';

const outputPath = path.resolve(process.cwd(), 'build');

/*
 * Remove project files here when webpack is loaded. Be sure it is not async.
 * 
 * Popular existing packages:
 * https://github.com/isaacs/rimraf
 * https://github.com/sindresorhus/del -- I prefer this one, great glob support and has CLI (del-cli package)
 * https://github.com/jprichardson/node-fs-extra
 *
 */
del.sync([path.resolve(outputPath, '**/*')]);

const webpackConfig = {
    entry: path.resolve(process.cwd(), 'src/index.js'),
    output: {
        path: outputPath,
        filename: 'bundle.js',
    },
};

export default webpackConfig;

If the goal of the project is to clean webpack's compilation files, I think it would be a good idea to talk about merging this plugin with gpbl/webpack-cleanup-plugin if both you and @gpbl would be open to it. In addition I think it would help if we add better documentation to clarify the goals of this plugins and put an example of how to clean the build directory before webpack starts (such as the one I wrote above).

Thoughts?

@johnagan
Copy link
Owner

Good feedback! I'm definitely open to it

@chrisblossom
Copy link
Collaborator Author

Do you feel the goal of this project is to clean Webpack's compilation files?

If merging is not an option, I could put together a minimal rewrite that would have a limited scope of clearing out the compilation files with possibly an explicit include option. Along with the documentation described above.

Another idea moving forward...it might be a good idea to look into moving this repo over to https://github.com/webpack-contrib/.

Just throwing around some thoughts.

@johnagan
Copy link
Owner

Do you feel the goal of this project is to clean Webpack's compilation files?

I'm open to whatever the community feels is the best decision here.

@chrisblossom
Copy link
Collaborator Author

@johnagan I went ahead and did a complete rewrite of this plugin chrisblossom/clean-self-webpack-plugin with the above goals in mind.

Let me know what you think / if you have any questions.

@chrisblossom
Copy link
Collaborator Author

@johnagan to be clear, I am open to merging chrisblossom/clean-self-webpack-plugin into this repo if that is the direction you'd like to go.

@johnagan
Copy link
Owner

johnagan commented Jul 5, 2017

Thanks for writing this @chrisblossom

My initial thought here is it appears a high risk of bringing this in and completely changing the code base with ~320k per month d/ls.

At this point, I'd rather a more popular clean library take over, rather than trying to keep up with another or solve for every use-case. I'm happy to maintain minor improvements, but I'm not as keen to a rewrite.

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

No branches or pull requests

2 participants