gshigeto / ionic-environment-variables

Easy to use environment variables for Ionic3!
MIT License
276 stars 36 forks source link

Building Ionic for Browser -- #39

Open aronAtWex opened 3 years ago

aronAtWex commented 3 years ago

I hope somebody is out there that can still help with this.
Out of the blue I'm not able to build an Ionic 3 app for browser. Can build fine for local (npm server) and can build ios and Android just fine. But when building for browser

MY_ENV=no ionic cordova build browser --prod --verbose

ENV no is set up. This just tells the code that there is no URL to hit. The code and the URL live on the same server.

Getting this error.

Error: ..filePage.ts
Module not found: Error: Can't resolve '@app/env' in '/filePage'
resolve '@app/env' in '/filePage'
  Parsed request is a module
  No description file found
  resolve as module
    looking for modules in /appRoot/node_modules
      using description file: /appRoot/package.json (relative path: ./node_modules)
        Field 'browser' doesn't contain a valid alias configuration
      after using description file: /appRoot/package.json (relative path: ./node_modules)
        using description file: /appRoot/package.json (relative path: ./node_modules/@app/env)
          no extension

Some reason it can't figure out what @app/env is. Code then tries to find it in node_modules goes down the wrong path.

Most of what is set up in this git hub is being used.

tsconfig.json

"paths": {
      "@angular/*": ["../node_modules/@angular/*"],
      "@app/env": [
         "environments/environment"
      ]
    }

In the custom /config/webpack.config.js setting up the @app/env for each environment

if(env == 'dev' || env == 'no')
{
  useDefaultConfig.dev.resolve.alias = {
    "@app/env": path.resolve(envPath)
  };
}
else
{
  useDefaultConfig.prod.resolve.alias = {
    "@app/env": path.resolve(envPath)
  };
}

I suspect maybe something with this isn't working anymore. app/env is empty ? Why only browser would be effected?

I don't know how to verify this is getting set up correctly.
I don't even know what to debug to get the browser version working.

I added and removed the browser "app". No change.
I have even uninstall node_modules and set them back up again. (maybe that did more harm).

Any ideas would be appreciated.