-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.js
50 lines (47 loc) · 1.4 KB
/
webpack.common.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
// https://www.youtube.com/playlist?list=PLblA84xge2_zwxh3XJqy6UVxS60YdusY8
const HtmlWebpackPlugin = require('html-webpack-plugin');
const projects = require('./src/data/projects.json');
const utils = require('./src/js/utils');
const plugins = [
new HtmlWebpackPlugin({
template: './src/templates/index.pug',
favicon: './src/images/favicon.png',
templateParameters: { utils, projects, title: 'ryan best', page: 'work' }
}),
new HtmlWebpackPlugin({
template: './src/templates/index.pug',
filename: 'about/index.html',
favicon: './src/images/favicon.png',
templateParameters: { utils, title: 'ryan best', page: 'about' }
})
];
const internalProjects = projects.filter(d => !d.url);
internalProjects.forEach(project => {
plugins.push(new HtmlWebpackPlugin({
template: './src/templates/index.pug',
filename: `${project.id}/index.html`,
favicon: './src/images/favicon.png',
templateParameters: { utils, projects, title: project.title, page: project.id, project: project }
}));
});
module.exports = {
entry: './src/js/app.js',
module: {
rules: [
// Include pug-loader to process the pug files
{
test: /\.pug$/,
use: ['pug-loader']
},
{
test: /\.(png|jpg|gif)$/i,
type: 'asset/resource'
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: 'asset/resource'
}
]
},
plugins
};