Skip to content
This repository was archived by the owner on Sep 14, 2022. It is now read-only.

Commit 6c23a84

Browse files
committed
reactor use resolve func
1 parent 806af6e commit 6c23a84

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

webpack.base.config.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ const webpack = require("webpack");
44
const FaviconsWebpackPlugin = require("favicons-webpack-plugin");
55
const CopyPlugin = require("copy-webpack-plugin");
66

7+
function resolveToProjRoot (relPath) {
8+
return path.resolve(__dirname, relPath);
9+
}
10+
711
module.exports = {
812
module: {
913
rules: [
@@ -21,13 +25,10 @@ module.exports = {
2125
/\/\@eslint\/.*\/config-array-factory/,
2226
/\/\@eslint\/.*\/relative-module-resolver/,
2327
/\/eslint\/eslint\.js/,
24-
// /\/@typescript-eslint\/experimental-utils\/dist\/ts-eslint/,
2528
/\/@typescript-eslint\/experimental-utils\/dist\/ts-eslint\/RuleTester.js/,
2629
/\/@typescript-eslint\/experimental-utils\/dist\/eslint-utils\/RuleTester.js/,
2730
/\/@typescript-eslint\/.*\/CLIEngine/,
28-
// /\/@typescript-eslint\/.*\/globby/,
2931
/\/@typescript-eslint\/.*\/create-program\/createWatchProgram.js/,
30-
/\.d\.ts$/,
3132
],
3233
use: "null-loader",
3334
},
@@ -66,24 +67,24 @@ module.exports = {
6667
plugins: [
6768
new webpack.NormalModuleReplacementPlugin(
6869
/resolve\-from/,
69-
path.resolve(__dirname, "./src/modules/resolve-from.js")
70+
resolveToProjRoot("src/modules/resolve-from.js")
7071
),
7172
new webpack.NormalModuleReplacementPlugin(
7273
/esquery/,
73-
path.resolve(__dirname, "./node_modules/esquery/dist/esquery.js")
74+
resolveToProjRoot("node_modules/esquery/dist/esquery.js")
7475
),
7576
new webpack.NormalModuleReplacementPlugin(
7677
/globby/,
77-
path.resolve(__dirname, "./src/modules/globby.js")
78+
resolveToProjRoot("src/modules/globby.js")
7879
),
7980
new HtmlPlugin({
8081
template: "./src/index.html",
8182
filename: "./index.html",
8283
}),
83-
new FaviconsWebpackPlugin(path.resolve(__dirname, "./assets/favicon.png")),
84+
new FaviconsWebpackPlugin(resolveToProjRoot("assets/favicon.png")),
8485
new CopyPlugin({
8586
patterns: [
86-
{ from: path.resolve(__dirname, "assets/share.png"), to: "assets" },
87+
{ from: resolveToProjRoot("assets/share.png"), to: "assets" },
8788
],
8889
}),
8990
],

0 commit comments

Comments
 (0)