web icon indicating copy to clipboard operation
web copied to clipboard

Trying to run the server in 4 different environments

Open saado-n opened this issue 4 years ago • 0 comments

Hi guys, I am trying to run the web server with different base URLs. I have this file src/config.ts:

export default {
  environment: 'development',
  x: 'https://dev-api-x.net',
};

This file src/config.qa.ts :

import config from './config.js';

export default {
  ...config,
  environment: 'qa',
  x: 'https://qa-api-x.net',
};

And my web-dev-server.config.js:

const mode = process.env.MODE || 'qa';
console.log('-----------------------');
console.log(mode);

export default {
  nodeResolve: { exportConditions: mode === 'dev' ? ['development'] : [] },
  preserveSymlinks: true,
  plugins: [
    legacyPlugin({
      polyfills: {
        // Manually imported in index.html file
        webcomponents: false,
      },
    }),
    esbuildPlugin({ ts: true }),
    ...(mode !== 'development'
      ? [
        console.log('-----------' + mode),
        fromRollup(replace)({
          preventAssignment: true,
          include: 'src/**/*.ts',
          exclude: 'src/config.*.ts',
          // delimiters: ['', ''],
          values: {
            './config.js': `./config.${mode}.js`,
          },
        }),
      ]
      : []),
  ],
};

I can't seems to run it in different env.

I am using this repo as a starter: https://github.com/lit/lit-element-starter-ts Could you please help? Thank you very much

saado-n avatar Jan 13 '22 19:01 saado-n