-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwebpack.config.js
More file actions
68 lines (66 loc) · 1.67 KB
/
webpack.config.js
File metadata and controls
68 lines (66 loc) · 1.67 KB
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
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const RemarkHTML = require("remark-html");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const { resolve } = require("path");
const mode =
process.env.NODE_ENV === "production" ? "production" : "development";
const isProduction = mode === "production";
module.exports = {
mode,
entry: "./index.js",
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
title:
"A gentle introduction to conflict-free replicated data types (CRDT) - Guillaume Bogard",
}),
new MiniCssExtractPlugin({
filename: isProduction ? "[name].[contenthash].css" : "[name].css",
}),
new CopyPlugin({ patterns: [{ from: "slides", to: "slides" }] }),
],
devServer: {
contentBase: "./dist",
hot: true,
historyApiFallback: true,
},
module: {
rules: [
{
test: /\.s[ac]ss$/i,
use: [MiniCssExtractPlugin.loader, "css-loader", "sass-loader"],
},
{
test: /\.md$/,
use: [
{
loader: "html-loader",
},
{
loader: "remark-loader",
options: {
remarkOptions: {
plugins: [RemarkHTML],
},
},
},
],
},
{
test: /\.png$/i,
use: [
{
loader: "file-loader",
},
],
},
],
},
output: {
filename: isProduction ? "[name].[contenthash].js" : "[name].js",
path: resolve(__dirname, "dist"),
publicPath: "/",
},
};