This repository has been archived by the owner on Sep 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebpack.base.config.js
94 lines (92 loc) · 2.46 KB
/
webpack.base.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
const path = require("path");
const HtmlPlugin = require("html-webpack-plugin");
const webpack = require("webpack");
const FaviconsWebpackPlugin = require("favicons-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
function resolveToProjRoot(relPath) {
return path.resolve(__dirname, relPath);
}
module.exports = {
module: {
rules: [
{
test: /\.(jsx|ts|tsx)$/,
use: {
loader: "babel-loader",
},
},
{
test: [
/\/eslint\/.*\/rule-tester/,
/\/eslint\/.*\/cli-engine/,
/\/resolve-from\/*/,
/\/\@eslint\/.*\/config-array-factory/,
/\/\@eslint\/.*\/relative-module-resolver/,
/\/eslint\/eslint\.js/,
/\/@typescript-eslint\/experimental-utils\/dist\/ts-eslint\/RuleTester.js/,
/\/@typescript-eslint\/experimental-utils\/dist\/eslint-utils\/RuleTester.js/,
/\/@typescript-eslint\/.*\/CLIEngine/,
/\/@typescript-eslint\/.*\/create-program\/createWatchProgram.js/,
],
use: "null-loader",
},
{
test: /\.html$/,
use: [
{
loader: "html-loader",
options: { minimize: true },
},
],
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"],
},
{
test: /\.png$/,
loader: "file-loader",
options: {
outputPath: "assets",
},
},
],
},
resolve: {
alias: [["@", "src"]].reduce(
(prev, [alias, origin]) => ({
...prev,
[alias]: path.resolve(__dirname, origin),
}),
{}
),
extensions: [".tsx", ".ts", ".js", ".jsx"],
},
plugins: [
new webpack.NormalModuleReplacementPlugin(
/resolve\-from/,
resolveToProjRoot("src/modules/resolve-from.js")
),
new webpack.NormalModuleReplacementPlugin(
/esquery/,
resolveToProjRoot("node_modules/esquery/dist/esquery.js")
),
new webpack.NormalModuleReplacementPlugin(
/globby/,
resolveToProjRoot("src/modules/globby.js")
),
new HtmlPlugin({
template: "./src/index.html",
filename: "./index.html",
}),
new FaviconsWebpackPlugin(resolveToProjRoot("assets/favicon.png")),
new CopyPlugin({
patterns: [{ from: resolveToProjRoot("assets/share.png"), to: "assets" }],
}),
],
output: {
filename: "[name].[hash].js",
chunkFilename: "[name].[hash].js",
publicPath: "/",
},
};