This repository has been archived by the owner on Nov 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
52 lines (48 loc) · 1.69 KB
/
webpack.config.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
const HtmlWebpackPlugin = require('html-webpack-plugin');
const posthtml = require('posthtml');
module.exports = {
mode: 'production',
entry: './index.js',
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: __dirname + `/index.html`
})
],
module: {
rules: [
{
test: /\.html$/i,
// With PostHTML Loader Config inside this file
// use: [
// "html-loader",
// {
// loader: 'posthtml-loader',
// // options: {
// // plugins: function () {
// // return [
// // require('posthtml-highlight')({ inline: true })
// // ]
// // }
// // }
// }
// ],
// With PostHTML used in html-loader preprocessor option
loader: "html-loader",
options: {
preprocessor: (content, loaderContext) => {
posthtml([
require('posthtml-highlight')({ inline: true }),
])
.process(content, { sync: true })
.then((result) => { return result.html })
.catch((error) => {
loaderContext.emitError(error);
return content;
})
}
},
},
],
}
};