Skip to content

Commit 8eaad0f

Browse files
committed
fix: fix production assets paths
1 parent 179b81d commit 8eaad0f

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

config-overrides.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,29 @@ const uiKitRoot = path.resolve(__dirname, 'node_modules/@gravity-ui/uikit');
55

66
module.exports = {
77
webpack: (config, env) => {
8-
//do stuff with the webpack config...
9-
108
const oneOfRule = config.module.rules.find((r) => r.oneOf);
119
oneOfRule.oneOf.splice(0, 0, {
1210
test: /\.svg$/,
1311
include: [path.resolve(srcRoot, 'assets/icons'), path.resolve(uiKitRoot, 'assets/icons')],
1412
loader: '@svgr/webpack',
1513
options: {dimensions: false},
1614
});
15+
1716
if (env === 'production') {
17+
oneOfRule.oneOf.splice(0, 0, {
18+
test: /\.svg$/,
19+
include: path.resolve(srcRoot, 'assets/illustrations'),
20+
loader: 'file-loader',
21+
options: {
22+
// default is 'static/media/...', but the embedded version static is served from 'resources/media/...',
23+
// and the 'resources' substring is handled by the publicPath below
24+
name: 'media/[name].[hash:8].[ext]',
25+
},
26+
});
1827
config.output.publicPath = 'resources/';
1928
config.output.path = path.resolve(__dirname, 'build/');
2029
}
30+
2131
return config;
2232
},
2333
jest: (config) => {

prepare-build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ set -e
55
cd build
66
mv static resources
77
mv favicon.png resources/
8+
mv media/* resources/media
9+
rm -r media
810

911
if [ "$(uname)" = "Darwin" ]; then # MacOSX case
1012
sed -i '' -e 's/static\///g; s/favicon\.png/resources\/favicon\.png/' index.html

0 commit comments

Comments
 (0)