-
Notifications
You must be signed in to change notification settings - Fork 12
/
webpack.config.prod.js
33 lines (29 loc) · 1 KB
/
webpack.config.prod.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
require('babel-core/register')
require('ignore-styles')
const getConfig = require('hjs-webpack')
const React = require('react')
const ReactDOMServer = require('react-dom/server')
const App = require('./src/views/app').default
const Index = require('./src/views/index').default
const Match = require('./src/views/match').default
const Helmet = require('react-helmet')
let config = getConfig({
in: 'src/app.js',
out: 'public',
clearBeforeBuild: '!(matches|img)',
html (context) {
function generateHtml (view) {
const html = `<div id="root">${ReactDOMServer.renderToString(React.createElement(App, {}, React.createElement(view)))}</div>`
const head = Helmet.rewind()
return {
html,
head: `${head.title.toString()}${head.meta.toString()}${head.script.toString()}${head.link.toString()}`
}
}
return {
'index.html': context.defaultTemplate(generateHtml(Index)),
'200.html': context.defaultTemplate(generateHtml(Match))
}
}
})
module.exports = config