From 940116fd2d8edf6437f2f075649b1c874c2b1112 Mon Sep 17 00:00:00 2001 From: Nastya <55718143+anrusina@users.noreply.github.com> Date: Wed, 20 Apr 2022 18:28:34 -0700 Subject: [PATCH] Fix: assets path for index.js query (#412) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix assets path for index.js query Signed-off-by: Alex Bain (Level 5 US)/Alex Bain * chore: remove item folder fof assets Signed-off-by: Nastya Rusina Co-authored-by: Alex Bain (Level 5 US)/Alex Bain --- index.js | 3 ++- webpack.config.ts | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index b258915274..2e79691fe9 100644 --- a/index.js +++ b/index.js @@ -28,7 +28,8 @@ if (process.env.NODE_ENV === 'production') { const clientStats = require('./dist/client-stats.json'); const distPath = path.join(__dirname, 'dist'); app.use( - `${env.BASE_URL}/`, + // This path should be in sync with the `publicPath` from webpack config. + `${env.BASE_URL}/assets`, expressStaticGzip(distPath, { maxAge: '1d', }), diff --git a/webpack.config.ts b/webpack.config.ts index e29ac14f35..f4be5dc250 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -25,8 +25,10 @@ export const serviceName = process.env.SERVICE_NAME || 'not set'; /** Absolute path to webpack output folder */ export const dist = path.join(__dirname, 'dist'); -/** Webpack public path. All emitted assets will have relative path to this path */ -export const publicPath = `${env.BASE_URL}/`; +/** Webpack public path. All emitted assets will have relative path to this path + * every time it is changed - the index.js app.use should also be updated. + */ +export const publicPath = `${env.BASE_URL}/assets/`; /** True if we are in development mode */ export const isDev = env.NODE_ENV === 'development'; @@ -107,7 +109,9 @@ export const htmlPlugin = new HTMLWebpackPlugin({ export const favIconPlugin = new FavIconWebpackPlugin({ logo: path.resolve(__dirname, 'src/assets/favicon.png'), - prefix: 'assets/', // we can add '[fullhash:8]/' to the end of the file in future + // we can add '[fullhash:8]/' to the end of the file in future + // if this one will be changed - ensure that OneClick will still be working + prefix: './', }); /** Write client stats to a JSON file for production */