Current working directory is not a Cordova-based project

After renaming www --> src I’m getting

Current working directory is not a Cordova-based project.

How would I go about getting this to play nice?

Why would you want to rename your www directory? It is an integral part of the Cordova project file structure.

1 Like

I think its a bad idea to rename any phone-gap file names especially www which is the main folder. Rename it and try again

Integral? That sounds rather flimsy to me if there isn’t a .config file or something where I can tell Cordova that my www directory is called something else…

In any case, Cordova isn’t being developed by the Ionic team, so your question might get more helpful responses on dedicated Phonegap / Cordova support avenues.

@blox the only thing i know that you can refer to in the Config file are application preferences, plugin, e.t.c .

From my experience you always leave www to be what it is besides why do you want to change it? My advice is that you stick to it.

@saniyusuf Larger projects are usually broken up into different build folders. Where my build scripts compile things from www the final output of that build actually live in build. If it was a release build it would be in release. If it was an android specific build it may live in android… etc…

Having everything live in www is not flexible enough for larger projects with different build configurations. Anyway, looking into Cordova docs for more info.

1 Like

@blox did you ever find a solution for this?

Cordova requires a ‘www’ folder, even if it’s empty. If it’s not there, you can’t add platforms or plugins because the CLI commands will throw the “current working directory is not a cordova-based project” error.

We prefer to keep our source code and other assets outside of the www (e.g./src or wherever), and then set our build tool to target www for build output artifacts. Since “cordova/ionic build xxx” is what actually builds the app, we think of transpiling/bundling/etc as a cordova pre-build step.

We make a distinction between web asset pre-build and cordova build because our webpack config is set up so that webpack-dev-server serves the www folder virtually to chrome using sourcemaps pointing back to our actual source files (.ts, .scss, etc.). It’s very fast to iterate since it auto-reloads without having to actually write anything there. We only generate actual pre-build artifacts in www for non-browser platform builds (we don’t bother with the ‘browser’ platform much, since it’s almost as slow as android or ios to build for it, and webpack is so much faster).

Even if we could configure cordova to use a different folder than www for bundling the web assets, I wouldn’t recommend it. I think it would add unnecessary confusion, since all cordova devs know at a glance that web assets in www get bundled in every platform build. I definitely recommend using it strictly as an output folder, though, and keeping source files elsewhere.