Skip to content

Commit e59da29

Browse files
committed
remove production source maps
1 parent 7be8e3b commit e59da29

1 file changed

Lines changed: 79 additions & 75 deletions

File tree

react_frontend/webpack.config.js

Lines changed: 79 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -27,84 +27,88 @@ const aliases = () => {
2727
return aliasConfig;
2828
};
2929

30-
module.exports = {
31-
entry: {
32-
main: "./src/index.tsx",
33-
},
34-
output: {
35-
filename: "js/[name].[contenthash:8].js",
36-
clean: true,
37-
},
38-
resolve: {
39-
alias: aliases(),
40-
extensions: [".js", ".jsx", ".ts", ".tsx", ".json"],
41-
modules: ["node_modules", path.resolve(__dirname, "node_modules")],
42-
},
43-
module: {
44-
rules: [
45-
{
46-
test: /\.(s*)css$/,
47-
use: [
48-
{
49-
loader: MiniCssExtractPlugin.loader,
50-
},
51-
{
52-
loader: "css-loader",
53-
options: {
54-
url: false,
55-
sourceMap: true,
30+
module.exports = (env, argv) => {
31+
const isProduction = argv.mode === "production";
32+
return {
33+
entry: {
34+
main: "./src/index.tsx",
35+
},
36+
output: {
37+
filename: "js/[name].[contenthash:8].js",
38+
clean: true,
39+
},
40+
resolve: {
41+
alias: aliases(),
42+
extensions: [".js", ".jsx", ".ts", ".tsx", ".json"],
43+
modules: ["node_modules", path.resolve(__dirname, "node_modules")],
44+
},
45+
module: {
46+
rules: [
47+
{
48+
test: /\.(s*)css$/,
49+
use: [
50+
{
51+
loader: MiniCssExtractPlugin.loader,
5652
},
57-
},
58-
"sass-loader",
59-
],
60-
},
61-
{
62-
test: /\.(js|jsx|ts|tsx)$/,
63-
exclude: /node_modules/,
64-
use: [
65-
{
66-
loader: "babel-loader",
67-
options: {
68-
presets: [
69-
"@babel/preset-env",
70-
["@babel/preset-react", { runtime: "automatic" }],
71-
"@babel/preset-typescript",
72-
],
53+
{
54+
loader: "css-loader",
55+
options: {
56+
url: false,
57+
sourceMap: true,
58+
},
59+
},
60+
"sass-loader",
61+
],
62+
},
63+
{
64+
test: /\.(js|jsx|ts|tsx)$/,
65+
exclude: /node_modules/,
66+
use: [
67+
{
68+
loader: "babel-loader",
69+
options: {
70+
presets: [
71+
"@babel/core",
72+
"@babel/preset-env",
73+
["@babel/preset-react", { runtime: "automatic" }],
74+
"@babel/preset-typescript",
75+
],
76+
},
7377
},
74-
},
75-
],
76-
},
77-
{
78-
test: /\.(png|jpg|gif)$/,
79-
type: "asset/resource",
80-
},
81-
{
82-
test: /\.svg$/i,
83-
use: [
84-
{
85-
loader: "@svgr/webpack",
86-
options: {
87-
svgoConfig: {
88-
plugins: [{ name: "preset-default", removeViewBox: false }],
78+
],
79+
},
80+
{
81+
test: /\.(png|jpg|gif)$/,
82+
type: "asset/resource",
83+
},
84+
{
85+
test: /\.svg$/i,
86+
use: [
87+
{
88+
loader: "@svgr/webpack",
89+
options: {
90+
svgoConfig: {
91+
plugins: [{ name: "preset-default", removeViewBox: false }],
92+
},
8993
},
9094
},
91-
},
92-
"file-loader",
93-
],
94-
},
95-
{
96-
test: /\.(zip)$/,
97-
use: "binary-loader",
98-
},
95+
"file-loader",
96+
],
97+
},
98+
{
99+
test: /\.(zip)$/,
100+
use: "binary-loader",
101+
},
102+
],
103+
},
104+
plugins: [
105+
new BundleTrackerPlugin({
106+
filename: "./webpack-stats.json",
107+
}),
108+
new MiniCssExtractPlugin({
109+
filename: "css/[name].css",
110+
}),
99111
],
100-
},
101-
plugins: [
102-
new BundleTrackerPlugin({
103-
filename: "./webpack-stats.json",
104-
}),
105-
new MiniCssExtractPlugin({
106-
filename: "css/[name].css",
107-
}),
108-
],
109-
devtool: "inline-source-map",
112+
devtool: isProduction ? false : "inline-source-map",
113+
};
110114
};

0 commit comments

Comments
 (0)