diff --git a/index.js b/index.js index b25891527..2e79691fe 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 e29ac14f3..f4be5dc25 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 */