Skip to content
Snippets Groups Projects
Commit 317dd7b4 authored by Lucendio's avatar Lucendio
Browse files

Allow to overwrite location of the client build folder

* keep both in gitignore, since the default still exist
parent 23896d41
No related branches found
No related tags found
No related merge requests found
node_modules
client/build
server/src/public
......@@ -21,6 +21,15 @@ const publicUrlOrPath = getPublicUrlOrPath(
process.env.PUBLIC_URL
);
// NOTE: env var supersedes default
//
const defaultBuildPath = resolveApp('./build');
const { BUILD_PATH = defaultBuildPath } = process.env;
if( BUILD_PATH.length <= 0 ){
process.error( new Error(`environment variable 'BUILD_PATH' is defined but empty`) );
}
const buildPath = path.resolve( BUILD_PATH );
const moduleFileExtensions = [
'web.mjs',
'mjs',
......@@ -52,7 +61,7 @@ const resolveModule = (resolveFn, filePath) => {
module.exports = {
dotenv: resolveApp('.env'),
appPath: resolveApp('.'),
appBuild: resolveApp('build'),
appBuild: buildPath,
appPublic: resolveApp('public'),
appHtml: resolveApp('public/index.html'),
appIndexJs: resolveModule(resolveApp, 'src/index'),
......
......@@ -33,7 +33,7 @@ app.use(helmet.contentSecurityPolicy({
app.use(todoRoutes);
app.use(userRoutes);
app.use('/', express.static(path.join(__dirname,`./../../client/build`)));
app.use('/', express.static(path.resolve(__dirname, `./public`)));
app.use(errorRoutes);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment