I am updating an angular 1.6 web app with gulp. I have my gulp watch task setup for local dev with browser-sync for auto-reloading my local source files. I am in the process of making a new gulp task build-prod minify/concat, etc. It seems like all the tutorials and readme's out there focus on either "local" or "production" setups. So, I am trying to figure out and read between the lines.
What is the best way to handle the node server.js file so that it knows src is local and dist is prod?
app.use('/scripts', express.static(__dirname + '/src/scripts/'));
app.use('/css', express.static(__dirname + '/src/css/'));
app.use('/html', express.static(__dirname + '/src/html'));
app.use('/img', express.static(__dirname + '/src/img'));
Needs to become:
app.use('/scripts', express.static(__dirname + '/dist/scripts/'));
app.use('/css', express.static(__dirname + '/dist/css/'));
app.use('/html', express.static(__dirname + '/dist/html'));
app.use('/img', express.static(__dirname + '/dist/img'));
Should I swap the src & dist with a variable or is there a better way to "use" these between multiple environments?
Use environment variables.
app.use('/scripts', express.static(`${__dirname}/${process.env.client_directory}`));
Then you set the environment variable in the process running the app.