-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.ts
65 lines (62 loc) · 1.62 KB
/
webpack.config.ts
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
import { GitRevisionPlugin } from "git-revision-webpack-plugin";
import HtmlWebpackPlugin from "html-webpack-plugin";
import MiniCssExtractPlugin from "mini-css-extract-plugin";
import webpack from "webpack";
const gitRevisionPlugin = new GitRevisionPlugin({
versionCommand: "describe --always --dirty",
});
const config: webpack.Configuration = {
output: {
filename: "[name].[contenthash].bundle.js",
assetModuleFilename: "[name].[hash][ext][query]",
publicPath: "",
},
resolve: {
fallback: {
fs: false,
https: false,
path: false,
},
extensions: [".ts", ".js"],
},
plugins: [
new MiniCssExtractPlugin({
filename: "[name].[contenthash].css",
chunkFilename: "[id].[contenthash].css",
}),
new HtmlWebpackPlugin({
template: "src/index.ejs",
}),
new webpack.DefinePlugin({
VERSION: JSON.stringify(gitRevisionPlugin.version()),
COMMITHASH: JSON.stringify(gitRevisionPlugin.commithash()),
}),
],
module: {
rules: [
{
test: /\.font\.js$/,
use: [
MiniCssExtractPlugin.loader,
{ loader: "css-loader", options: { url: false } },
{ loader: "webfonts-loader", options: { publicPath: "" } },
],
},
{
test: /\.(js|ts)$/,
exclude: /\.font\.js$|node_modules/,
loader: "babel-loader",
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, "css-loader"],
},
{
test: /\.(?:eot|ico|png|svg|ttf|woff|woff2)$/,
type: "asset/resource",
},
],
},
devtool: "source-map",
};
export default config;