-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
109 lines (106 loc) · 3.21 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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-env node */
import path from "path";
import { fileURLToPath } from "url";
import CopyPlugin from "copy-webpack-plugin";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
import RemarkHTML from "remark-html";
import { CleanWebpackPlugin } from "clean-webpack-plugin";
import CompressionPlugin from 'compression-webpack-plugin';
import webpack from "webpack";
const module = {
entry: {
index: "./ts/main.ts"
},
devServer: {
static: {
directory: path.join(__dirname, 'public'),
},
compress: true,
port: 8080,
},
output: {
filename: "js/[name].bundle.js",
chunkFilename: "js/[name].chunk.js",
publicPath: "public/",
path: path.resolve(__dirname, "public/")
},
plugins: [
new CopyPlugin({
patterns: [
{ from: "favicon.ico", to: "favicon.ico" },
{ from: "index.html", to: "index.html" },
{ from: "css", to: "css" },
{ from: "img", to: "img" }
]
}),
new CompressionPlugin(),
new webpack.DefinePlugin({
'process.env.ASSET_PATH': JSON.stringify(`./`),
}),
// new CleanWebpackPlugin({
// dangerouslyAllowCleanPatternsOutsideProject: true,
// dry: false
// })
],
module: {
rules: [
{
test: /\.tsx?$/i,
use: [
{
loader: "babel-loader",
options: { presets: ["@babel/preset-env"] }
},
{ loader: "ts-loader" }
]
},
{
test: /\.js$/i,
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-env"],
plugins: [
[
"@babel/plugin-transform-react-jsx",
{
"importSource": "@herp-inc/snabbdom-jsx",
"runtime": "automatic"
}
]
]
}
}
},
{
test: /\.html$/,
exclude: /node_modules/,
use: { loader: 'html-loader' }
},
{
test: /\.md$/,
use: [
{
loader: "html-loader"
},
{
loader: "remark-loader",
options: {
remarkOptions: {
plugins: [RemarkHTML]
}
}
}
]
},
{
test: /\.css$/i,
use: ["style-loader", "css-loader"]
}
]
},
resolve: { extensions: [".ts", ".tsx", ".js"] },
};
export default module;