Skip to content

Commit 653750b

Browse files
committed
🌈 Deployment improvement. Added static files prefix.
1 parent a39e2fe commit 653750b

File tree

5 files changed

+39
-34
lines changed

5 files changed

+39
-34
lines changed

‎env-config.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const prod = process.env.NODE_ENV === 'production';
2+
3+
const URL = '/value-driven-templates';
4+
5+
module.exports = {
6+
'process.env.BACKEND_URL': prod ? URL : '',
7+
'process.env.ASSET_PREFIX': URL,
8+
};

‎next.config.js

+16
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
11
const withSass = require('@zeit/next-sass');
22
const withLess = require('@zeit/next-less');
33

4+
const webpack = require('webpack');
5+
6+
const isProd = (process.env.NODE_ENV || 'production') === 'production';
7+
8+
const assetPrefix = isProd ? '/value-driven-templates' : '';
9+
410
if (typeof require !== 'undefined') {
511
require.extensions['.less'] = () => {};
612
}
713

814
module.exports = withLess(
915
withSass({
16+
assetPrefix,
1017
lessLoaderOptions: {
1118
javascriptEnabled: true,
1219
},
20+
webpack: (config) => {
21+
config.plugins.push(
22+
new webpack.DefinePlugin({
23+
'process.env.ASSET_PREFIX': JSON.stringify(assetPrefix),
24+
})
25+
);
26+
27+
return config;
28+
},
1329
})
1430
);

‎src/router/app-routes.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export enum AppRoute {
2+
HOME = '',
3+
ABOUT = '/about',
4+
HOW_TO_CONTRIBUTE = '/how-to-contribute',
5+
}
6+
7+
export const getLink = (route: AppRoute) => `${process.env.ASSET_PREFIX}/${route}`;

‎src/ui/navigation/navigation.component.tsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
NavigationItem,
1010
NavigationLink,
1111
} from './navigation.styles';
12+
import { AppRoute } from '../../router/app-routes';
1213

1314
export const Navigation = () => {
1415
const { isMobile } = useDeviceDetect();
@@ -20,18 +21,22 @@ export const Navigation = () => {
2021

2122
return (
2223
<StyledNavigation>
23-
<Logo>value driven templates</Logo>
24+
<Link href={AppRoute.HOME}>
25+
<a>
26+
<Logo>value driven templates</Logo>
27+
</a>
28+
</Link>
2429
{isMobile ? (
2530
<Hamburger active={isMobileMenuVisible} onClick={onMobileMenuClick} />
2631
) : (
2732
<ItemList>
2833
<NavigationItem>
29-
<Link href="/about">
34+
<Link href={AppRoute.ABOUT}>
3035
<NavigationLink>About</NavigationLink>
3136
</Link>
3237
</NavigationItem>
3338
<NavigationItem>
34-
<Link href="/how-to-contribute">
39+
<Link href={AppRoute.HOW_TO_CONTRIBUTE}>
3540
<NavigationLink>How to contribute</NavigationLink>
3641
</Link>
3742
</NavigationItem>

‎static/animations.css

-31
This file was deleted.

0 commit comments

Comments
 (0)