-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.js
93 lines (91 loc) · 2.07 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
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
const webpack = require('webpack');
const path = require('path');
const fs = require('fs');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
class MyCleanPlugin {
apply(compiler) {
compiler.hooks.compilation.tap('Clean', (compilation) => {
fs.rmSync(compilation.options.output.path, { recursive: true, force: true });
});
}
}
module.exports = {
entry: {
app: './src/bootstrap.ts',
},
plugins: [
new MyCleanPlugin(),
new FaviconsWebpackPlugin({
logo: './src/images/reflect_cropped.jpg',
prefix: '',
favicons: {
icons: {
android: false,
appleIcon: false,
appleStartup: false,
coast: false,
windows: false,
yandex: false,
firefox: false,
},
},
}),
new HtmlWebpackPlugin({
title: "Sinewyk's Stuff",
author: "Serge 'Sinewyk' Havas",
keywords: 'sinewyk,blog,functional,programming,random,stuff',
description: 'Where I create and talk about stuff, my personal playground',
template: 'public/index.ejs',
}),
new CopyWebpackPlugin({ patterns: [{ from: 'static', to: '' }] }),
new webpack.DefinePlugin({
__LAST_BUILD_TIME__: Date.now(),
// Dev mode inside @cycle/time or something
'process.env': {},
// Dev mode inside @cycle/time or something
'process.argv': '""',
process: {},
assert: require('assert'),
}),
],
module: {
rules: [
{
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/i,
type: 'asset',
},
{
test: /\.ts?$/,
use: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.md$/,
use: [
{
loader: './scripts/gitMetaLoader',
},
{
loader: 'html-loader',
options: {
esModule: true,
},
},
'markdown-loader',
],
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.ts', '.js', '.json'],
modules: ['src', 'node_modules'],
},
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist'),
publicPath: 'auto',
},
};