Skip to content

Instantly share code, notes, and snippets.

@bbachi
Created January 12, 2023 02:04
Show Gist options
  • Select an option

  • Save bbachi/3ad2734e12a166e22a4b9b7526d6823c to your computer and use it in GitHub Desktop.

Select an option

Save bbachi/3ad2734e12a166e22a4b9b7526d6823c to your computer and use it in GitHub Desktop.
PERN
const path = require('path');
const webpack = require('webpack');
const environment = process.env.ENVIRONMENT;
console.log('environment:::::', environment);
let ENVIRONMENT_VARIABLES = {
'process.env.HOST': JSON.stringify('130.211.121.102'),
'process.env.USER': JSON.stringify('admin'),
'process.env.PASSWORD': JSON.stringify('tester'),
'process.env.DB': JSON.stringify('tasks'),
'process.env.DIALECT': JSON.stringify('postgres'),
'process.env.PORT': JSON.stringify('80'),
'process.env.PG_CONNECTION_STR': JSON.stringify("postgres://bhargavbachina:''@localhost:5432/bhargavbachina")
};
if (environment === 'test') {
ENVIRONMENT_VARIABLES = {
'process.env.HOST': JSON.stringify('localhost'),
'process.env.USER': JSON.stringify('admin'),
'process.env.DB': JSON.stringify('tester'),
'process.env.DIALECT': JSON.stringify('postgres'),
'process.env.PORT': JSON.stringify('3080'),
'process.env.PG_CONNECTION_STR': JSON.stringify("postgres://bhargavbachina:''@localhost:5432/bhargavbachina")
};
} else if (environment === 'production') {
ENVIRONMENT_VARIABLES = {
'process.env.HOST': JSON.stringify('130.211.121.102'),
'process.env.USER': JSON.stringify('admin'),
'process.env.PASSWORD': JSON.stringify('tester'),
'process.env.DB': JSON.stringify('tasks'),
'process.env.DIALECT': JSON.stringify('postgres'),
'process.env.PORT': JSON.stringify('80'),
'process.env.PG_CONNECTION_STR': JSON.stringify("postgres://pgadmin@webappdemopostgre:Admin@[email protected]:5432/tasks")
};
}
module.exports = {
entry: './server.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'api.bundle.js',
libraryTarget: 'commonjs'
},
target: 'node',
plugins: [
new webpack.DefinePlugin(ENVIRONMENT_VARIABLES),
],
//externals: ['pg', 'pg-hstore']
externals: [
{ pg: { commonjs: ['pg'] } },
{ 'pg-hstore': { commonjs: ['pg-hstore'] } }
],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment