-
Notifications
You must be signed in to change notification settings - Fork 136
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
Error: "project root is outside of project" #17
Comments
@alextreppass I'm not opposed to it. Is it something you can propose in a PR? |
@alextreppass You do not need to change anything. Where var CleanWebpackPlugin = require('clean-webpack-plugin');
module.exports = {
plugins: [
new CleanWebpackPlugin(['dist', 'build'], {
root: '/full/project/path/server/public',
verbose: true,
dry: false
})
]
} |
I'll give it a go, thanks! |
Hmm still running into that issue I'm afraid. The error message I get is: Here's my config: new CleanWebpackPlugin(['scripts', 'styles'], {
root: TARGET_DIR,
verbose: true,
dry: false
}),
From within the client dir, it's a traversal of I'll fork and see if I can get it working. Bear with me! |
@alextreppass Could you provide a failing test case? test/test.js |
I believe this is showing the issue: it('root outside of process.cwd()', function () {
var outsideProjectDirOne = '/test/dir/_one';
// outsideProjectDir === '/test/dir'
cleanWebpackPlugin =
new CleanWebpackPlugin([outsideProjectDirOne], { root: outsideProjectDir, dry: true });
result = cleanWebpackPlugin.apply();
expect(result[0].output).to.equal('removed');
}); index.js#L89 is where the check is failing. |
Here's a diff where I've got it working for my needs: alextreppass@a098e76 It doesn't seem that webpack exposes wider config (like I also had to remove the I'm seeing if I can tweak the tests now. I'm adding some folders in the test setup to verify my approach |
I don't think removing all of the safety checks is a good solution. Try my latest branch https://github.com/chrisblossom/clean-webpack-plugin |
Got the tests passing in #18 - I had missed the I think I removed only the checks that were ensuring the root was under the project dir. I've tried to ensured that any dirs to be deleted must be under the given 'root' dir (unrelated to the project / working dir). |
Nice, your approach works great, just tested it here locally. 👍 I guess the question for your consideration is:
I'd be happy with either :) |
Just checking to make sure the files being deleted is inside of Also, I don't think it would break anyone's current config. Thoughts? Only downside I can think of it potentially makes the plugin less "safe" from deleting files/directories by mistake. |
Yeah it might be more portable -- do webpack document the I googled around a bit for Semantics - yeah I agree it'd be compatible with current config, we're still telling the plugin I agree the potential danger is the main concern. As you say, what if the user mistakenly puts in a root value that they shouldn't? How about a new config option like |
I am happy with removing the process.cwd()/running directory check as long as absolute root paths for |
@alextreppass I'd want @chrisblossom's sign-off because some of this is his code too. |
I created a PR@alextreppass#1 for @alextreppass to look over. Everything looks good to me outside of that. |
Hey thanks, I'll integrate this into #18. Edit: that's now done, let me know if you want me to make any more changes! |
@chrisblossom / @johnagan - I merged Chris' alextreppass#1 code into my branch; #18 is ready to go if you guys are happy. Thanks! |
Looks good to me. |
Deployed v0.1.9 to npm. Thanks everyone 👍 |
Cheers 👍 |
Does not for work projects with multiple workspaces, where there is some webpack.config.base.js injecting clean-webpack-plugin in it located in another folder outside the subpackage. |
Hi,
Due to various reasons in our project, the client builds into the 'public' folder of our rails app. For illustration purposes:
server/client
- client dir (wherewebpack.config.js
lives), and where the build is run fromserver/public
- webpackconfig.output.path
dir, where webpack builds relative toIt looks like this plugin relies on
workingDir
(i.e.process.cwd()
) over webpack'sconfig.output.path
.Would it be ok to change this? Webpack is building happily into a folder that isn't the cwd.
What I'm looking for is to remove / clean the files pre-build, in:
server/public/scripts
andserver/public/styles
server/public
intactThanks!
The text was updated successfully, but these errors were encountered: