-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.pages.js
57 lines (48 loc) · 1.46 KB
/
webpack.pages.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
/* eslint-disable import/no-extraneous-dependencies */
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const template = './src/layout.html'
const pages = [
{ name: 'georg-nees', title: 'Georg Nees' },
{ name: 'circle-packing', title: 'Circle Packing' },
{ name: 'watercolour', title: 'Watercolour' },
{ name: 'triangle-subdivision', title: 'Triangle Subdivision' },
{ name: 'clock-of-clocks', title: 'Clock of Clocks' },
{ name: 'flow-field', title: 'Perlin Flow Field' },
{ name: 'text-pathing', title: 'Text Pathing' },
{ name: 'isometric', title: 'Isometric' },
{ name: 'terrariums', title: 'Terrariums' },
]
const buildPages = ({ SRC }) => {
const entry = pages.reduce((out, { name }) => ({
...out,
[name]: path.join(SRC, name),
}), {
index: SRC,
})
const plugins = [
new HtmlWebpackPlugin({
filename: 'index.html',
template: './src/index.html',
chunks: ['index'],
inject: false,
pages,
}),
]
pages.forEach(({ name, title }) => {
plugins.push(new HtmlWebpackPlugin({
title,
filename: `${name}/index.html`,
chunks: [name],
inject: false,
template,
}))
const thumbnail = `${name}/thumbnail.png`
plugins.push(new CopyWebpackPlugin([
{ from: path.join(SRC, thumbnail), to: thumbnail },
]))
})
return { entry, plugins }
}
module.exports = buildPages