floatinghotpot / cordova-httpd

Embed tiny web server into Cordova with a plugin
284 stars 149 forks source link

Allow specification of the `www` dir to allow compatibility with Ionic + Capacitor builds #77

Open colossatr0n opened 3 years ago

colossatr0n commented 3 years ago

In Ionic + Capacitor IOS builds the www directory is called public.

If the www directory name could be specified in the config, then Ionic + Capacitor users could benefit from this plugin.

To maintain backwards compatibility for Cordova users, a www_dir_name variable could be added to the config that would allow the user to specify the name of the www directory:

var capacitorCompatibleConfig = {
        'www_dir_name': 'public',  // NEW: Use "public" instead of "www"
    'www_root': '',           // Defaults to www_dir_name, which is now "public".
    'port': 8888,
    'localhost_only': false
};

// Backwards compatible defaults for Cordova users
var default = {
        'www_dir_name': 'www',  // Set default to www
    'www_root': '',         // Defaults to www_dir_name, which is www
    'port': 8888,
    'localhost_only': false
};

Both this issue and this issue will need to be resolved to fully support Ionic + Capacitor builds.