forked from lorikeetui/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
static.config.js
108 lines (99 loc) · 2.86 KB
/
static.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import path from 'path'
import React from 'react'
import CopyWebpackPlugin from 'copy-webpack-plugin'
import ExtractTextPlugin from 'extract-text-webpack-plugin'
import { ServerStyleSheet } from 'styled-components'
const REACT_STATIC_PATHS = {
src: 'src',
dist: 'dist',
devDist: 'dist',
public: 'public',
}
const ARAGON_UI_ASSETS = path.dirname(require.resolve('@aragon/ui'))
export default {
siteRoot: process.env.SITE_ROOT || '',
basePath: process.env.BASE_PATH || '',
getSiteData: () => ({
title: 'Lorikeet website',
basePath: '/' + process.env.BASE_PATH || '',
}),
getRoutes: () => [
{
path: '/',
component: 'src/pages/Home',
getData: () => ({ title: 'Lorikeet' }),
},
{
path: '/downloads',
component: 'src/pages/Downloads',
getData: () => ({ title: 'Lorikeet - Downloads' }),
},
{
is404: true,
component: 'src/pages/NotFound',
getData: () => ({ title: 'Lorikeet - Page Not Found' }),
},
],
paths: REACT_STATIC_PATHS,
webpack: (conf, { defaultLoaders }) => {
conf.resolve = Object.assign({}, conf.resolve || {}, {
modules: ((conf.resolve && conf.resolve.modules) || []).concat([
path.join(__dirname, 'node_modules'),
path.join(__dirname, REACT_STATIC_PATHS.dist),
]),
})
conf.plugins = (conf.plugins || []).concat([
new CopyWebpackPlugin([
{
from: ARAGON_UI_ASSETS,
to: path.resolve(
path.join(__dirname, REACT_STATIC_PATHS.dist, 'aragon-ui')
),
},
]),
])
const fileLoader = defaultLoaders.fileLoader
fileLoader.query.name = 'static/[hash:8]-[name].[ext]'
conf.module.rules = [
{
oneOf: [defaultLoaders.jsLoader, defaultLoaders.cssLoader, fileLoader],
},
]
conf.plugins.push(new ExtractTextPlugin('app.css'))
return conf
},
renderToHtml: (render, Comp, meta) => {
const sheet = new ServerStyleSheet()
const html = render(sheet.collectStyles(<Comp />))
meta.styleTags = sheet.getStyleElement()
return html
},
Document: class CustomHtml extends React.Component {
render() {
const {
Html,
Head,
Body,
siteData: { title: siteTitle },
children,
renderMeta,
routeInfo: { allProps: { title } = {} } = {},
} = this.props
return (
<Html>
<Head>
<meta charSet="UTF-8" />
<title>{title || siteTitle}</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script id="twitter-wjs" type="text/javascript" async defer src="//platform.twitter.com/widgets.js"></script>
<link rel="icon" href="/favicon.ico" />
{renderMeta.styleTags}
</Head>
<Body>
{children}
</Body>
</Html>
)
}
},
}