-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.prod.js
57 lines (54 loc) · 1.43 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const fs = require('fs');
const path = require("path");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const Marked = require("marked");
const RemarkHTML = require('remark-html');
const WorkboxWebpackPlugin = require("workbox-webpack-plugin");
const markdownFilepath = './readme.md';
const templateHtmlFilepath = "./gh-pages/index.html";
const importedMarkdown = fs.readFileSync(path.join(__dirname, markdownFilepath), 'utf8');
module.exports = {
plugins: [
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: ["**/*", "!.git/**"]
}),
new HtmlWebpackPlugin({
template: templateHtmlFilepath,
minify: { collapseWhitespace: true, removeComments: true },
inject: false,
html: Marked(importedMarkdown)
}),
new CopyWebpackPlugin({
patterns: [
"./src/manifest.json",
"./src/assets"
]
}),
new WorkboxWebpackPlugin.InjectManifest({
swSrc: "./src/src-sw.js",
swDest: "sw.js"
})
],
module: {
rules: [
{
test: /\.md$/,
use: [
{
loader: 'html-loader',
},
{
loader: 'remark-loader',
options: {
remarkOptions: {
plugins: [RemarkHTML],
},
},
},
],
},
]
}
}