3

I would like to build my featherjs app for production. I am using feathersjs with vuejs.

According to https://docs.feathersjs.com/api/configuration.html, there is a default.json and production.json. I can input the host and port for the production.json.

I don't know how to change the app.js to use this production.json.

This is the app.js

const path = require('path');
const favicon = require('serve-favicon');
const compress = require('compression');
const helmet = require('helmet');
const cors = require('cors');
const logger = require('./logger');

const feathers = require('@feathersjs/feathers');
const configuration = require('@feathersjs/configuration');
const express = require('@feathersjs/express');
const socketio = require('@feathersjs/socketio');


const middleware = require('./middleware');
const services = require('./services');
const appHooks = require('./app.hooks');
const channels = require('./channels');

const mongoose = require('./mongoose');

const authentication = require('./authentication');

const app = express(feathers());

// Load app configuration
app.configure(configuration());
// Enable security, CORS, compression, favicon and body parsing
app.use(helmet());
app.use(cors());
app.use(compress());
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(favicon(path.join(app.get('public'), 'favicon.ico')));
// Host the public folder
app.use('/', express.static(app.get('public')));

how to i build feathersjs for production?

Ninja Dude
  • 1,332
  • 4
  • 27
  • 54

2 Answers2

4

According to docs, it searches for a NODE_ENV environment variable:

production.json files override default.json when in production mode by setting NODE_ENV=production.

guijob
  • 4,413
  • 3
  • 20
  • 39
2

Example of setting NODE_ENV=production is by setting your package.json file like this:

"start": "npm run compile && NODE_ENV=production node lib/",

When you run npm start, it will merge your default.json with production.json

Arfina Arfwani
  • 166
  • 3
  • 3