Hi i am starting a project of nodejs app with angular7. This is my mail server.js file in nodejs
var express = require('express');
var mysql = require('mysql');
var bodyParser = require('body-parser')
var cookieParser = require('cookie-parser');
var router = express.Router();
var app = express();
app.use(cookieParser());
app.use( bodyParser.json() ); // to support JSON-encoded bodies
app.use(bodyParser.urlencoded({ // to support URL-encoded bodies
extended: true
}));
app.set('view engine', 'pug');
app.set('views', __dirname + '/app/views');
app.use(express.static(__dirname + '/public'));
app.use('/', express.static(__dirname + '/angular/src'));
require('./app/routes')(router);
app.use(router);
app.listen(2233, function(){
console.log('app started on 2233');
});
This line app.use('/', express.static(__dirname + '/angular/src')); indicates that i want to render src folder inside angular folder on nodejs app load but this is rendering blank screen. When i run ng build and change it to app.use('/', express.static(__dirname + '/angular/dist')); then start working.
All the tutorial showing to run ng build and run angular inside node but why can i use src folder inside nodejs.
srcfiles though? Your built files are in thedistfolderng buildto minify the files and use light weight app on production. When we create new project it opens on browser onhttp://localhost:4200/but that works onsrcfolder then on production we useng buildand servedistfolder. I am usingsrcfolder as its hard to runng buildafter every small change. I will runng buildand change it todiston production. And also there is little curiosity why its not working onsrc