Skip to content

Commit 635d2e4

Browse files
committed
feat: support settings
1 parent 415abb3 commit 635d2e4

23 files changed

+18795
-18958
lines changed

.erb/configs/webpack.config.main.prod.ts

+54-53
Original file line numberDiff line numberDiff line change
@@ -13,71 +13,72 @@ import checkNodeEnv from '../scripts/check-node-env';
1313
import deleteSourceMaps from '../scripts/delete-source-maps';
1414

1515
checkNodeEnv('production');
16-
deleteSourceMaps();
16+
// deleteSourceMaps();
1717

1818
const configuration: webpack.Configuration = {
19-
devtool: 'source-map',
19+
devtool: 'source-map',
2020

21-
mode: 'production',
21+
mode: 'production',
2222

23-
target: 'electron-main',
23+
target: 'electron-main',
2424

25-
entry: {
26-
main: path.join(webpackPaths.srcMainPath, 'main.ts'),
27-
preload: path.join(webpackPaths.srcMainPath, 'preload.ts'),
28-
},
25+
entry: {
26+
main: path.join(webpackPaths.srcMainPath, 'main.ts'),
27+
preload: path.join(webpackPaths.srcMainPath, 'preload.ts'),
28+
},
2929

30-
output: {
31-
path: webpackPaths.distMainPath,
32-
filename: '[name].js',
33-
library: {
34-
type: 'umd',
30+
output: {
31+
path: webpackPaths.distMainPath,
32+
filename: '[name].js',
33+
library: {
34+
type: 'umd',
35+
},
3536
},
36-
},
3737

38-
optimization: {
39-
minimizer: [
40-
new TerserPlugin({
41-
parallel: true,
42-
}),
43-
],
44-
},
38+
optimization: {
39+
minimizer: [
40+
new TerserPlugin({
41+
parallel: true,
42+
}),
43+
],
44+
},
4545

46-
plugins: [
47-
new BundleAnalyzerPlugin({
48-
analyzerMode: process.env.ANALYZE === 'true' ? 'server' : 'disabled',
49-
analyzerPort: 8888,
50-
}),
46+
plugins: [
47+
new BundleAnalyzerPlugin({
48+
analyzerMode:
49+
process.env.ANALYZE === 'true' ? 'server' : 'disabled',
50+
analyzerPort: 8888,
51+
}),
5152

52-
/**
53-
* Create global constants which can be configured at compile time.
54-
*
55-
* Useful for allowing different behaviour between development builds and
56-
* release builds
57-
*
58-
* NODE_ENV should be production so that modules do not perform certain
59-
* development checks
60-
*/
61-
new webpack.EnvironmentPlugin({
62-
NODE_ENV: 'production',
63-
DEBUG_PROD: false,
64-
START_MINIMIZED: false,
65-
}),
53+
/**
54+
* Create global constants which can be configured at compile time.
55+
*
56+
* Useful for allowing different behaviour between development builds and
57+
* release builds
58+
*
59+
* NODE_ENV should be production so that modules do not perform certain
60+
* development checks
61+
*/
62+
new webpack.EnvironmentPlugin({
63+
NODE_ENV: 'production',
64+
DEBUG_PROD: false,
65+
START_MINIMIZED: false,
66+
}),
6667

67-
new webpack.DefinePlugin({
68-
'process.type': '"browser"',
69-
}),
70-
],
68+
new webpack.DefinePlugin({
69+
'process.type': '"browser"',
70+
}),
71+
],
7172

72-
/**
73-
* Disables webpack processing of __dirname and __filename.
74-
* If you run the bundle in node.js it falls back to these values of node.js.
75-
* https://github.com/webpack/webpack/issues/2010
76-
*/
77-
node: {
78-
__dirname: false,
79-
__filename: false,
80-
},
73+
/**
74+
* Disables webpack processing of __dirname and __filename.
75+
* If you run the bundle in node.js it falls back to these values of node.js.
76+
* https://github.com/webpack/webpack/issues/2010
77+
*/
78+
node: {
79+
__dirname: false,
80+
__filename: false,
81+
},
8182
};
8283

8384
export default merge(baseConfig, configuration);

.erb/configs/webpack.config.renderer.prod.ts

+109-108
Original file line numberDiff line numberDiff line change
@@ -16,131 +16,132 @@ import checkNodeEnv from '../scripts/check-node-env';
1616
import deleteSourceMaps from '../scripts/delete-source-maps';
1717

1818
checkNodeEnv('production');
19-
deleteSourceMaps();
19+
// deleteSourceMaps();
2020

2121
const configuration: webpack.Configuration = {
22-
devtool: 'source-map',
22+
devtool: 'source-map',
2323

24-
mode: 'production',
24+
mode: 'production',
2525

26-
target: ['web', 'electron-renderer'],
26+
target: ['web', 'electron-renderer'],
2727

28-
entry: [path.join(webpackPaths.srcRendererPath, 'index.tsx')],
28+
entry: [path.join(webpackPaths.srcRendererPath, 'index.tsx')],
2929

30-
output: {
31-
path: webpackPaths.distRendererPath,
32-
publicPath: './',
33-
filename: 'renderer.js',
34-
library: {
35-
type: 'umd',
30+
output: {
31+
path: webpackPaths.distRendererPath,
32+
publicPath: './',
33+
filename: 'renderer.js',
34+
library: {
35+
type: 'umd',
36+
},
3637
},
37-
},
3838

39-
module: {
40-
rules: [
41-
{
42-
test: /\.s?(a|c)ss$/,
43-
use: [
44-
MiniCssExtractPlugin.loader,
45-
{
46-
loader: 'css-loader',
47-
options: {
48-
modules: true,
49-
sourceMap: true,
50-
importLoaders: 1,
39+
module: {
40+
rules: [
41+
{
42+
test: /\.s?(a|c)ss$/,
43+
use: [
44+
MiniCssExtractPlugin.loader,
45+
{
46+
loader: 'css-loader',
47+
options: {
48+
modules: true,
49+
sourceMap: true,
50+
importLoaders: 1,
51+
},
52+
},
53+
'sass-loader',
54+
],
55+
include: /\.module\.s?(c|a)ss$/,
5156
},
52-
},
53-
'sass-loader',
54-
],
55-
include: /\.module\.s?(c|a)ss$/,
56-
},
57-
{
58-
test: /\.s?(a|c)ss$/,
59-
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
60-
exclude: /\.module\.s?(c|a)ss$/,
61-
},
62-
// Fonts
63-
{
64-
test: /\.(woff|woff2|eot|ttf|otf)$/i,
65-
type: 'asset/resource',
66-
},
67-
// Images
68-
{
69-
test: /\.(png|jpg|jpeg|gif)$/i,
70-
type: 'asset/resource',
71-
},
72-
// SVG
73-
{
74-
test: /\.svg$/,
75-
use: [
76-
{
77-
loader: '@svgr/webpack',
78-
options: {
79-
prettier: false,
80-
svgo: false,
81-
svgoConfig: {
82-
plugins: [{ removeViewBox: false }],
83-
},
84-
titleProp: true,
85-
ref: true,
57+
{
58+
test: /\.s?(a|c)ss$/,
59+
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
60+
exclude: /\.module\.s?(c|a)ss$/,
61+
},
62+
// Fonts
63+
{
64+
test: /\.(woff|woff2|eot|ttf|otf)$/i,
65+
type: 'asset/resource',
66+
},
67+
// Images
68+
{
69+
test: /\.(png|jpg|jpeg|gif)$/i,
70+
type: 'asset/resource',
71+
},
72+
// SVG
73+
{
74+
test: /\.svg$/,
75+
use: [
76+
{
77+
loader: '@svgr/webpack',
78+
options: {
79+
prettier: false,
80+
svgo: false,
81+
svgoConfig: {
82+
plugins: [{ removeViewBox: false }],
83+
},
84+
titleProp: true,
85+
ref: true,
86+
},
87+
},
88+
'file-loader',
89+
],
8690
},
87-
},
88-
'file-loader',
8991
],
90-
},
91-
],
92-
},
92+
},
9393

94-
optimization: {
95-
minimize: true,
96-
minimizer: [
97-
new TerserPlugin({
98-
parallel: true,
99-
}),
100-
new CssMinimizerPlugin(),
101-
],
102-
},
94+
optimization: {
95+
minimize: true,
96+
minimizer: [
97+
new TerserPlugin({
98+
parallel: true,
99+
}),
100+
new CssMinimizerPlugin(),
101+
],
102+
},
103103

104-
plugins: [
105-
/**
106-
* Create global constants which can be configured at compile time.
107-
*
108-
* Useful for allowing different behaviour between development builds and
109-
* release builds
110-
*
111-
* NODE_ENV should be production so that modules do not perform certain
112-
* development checks
113-
*/
114-
new webpack.EnvironmentPlugin({
115-
NODE_ENV: 'production',
116-
DEBUG_PROD: false,
117-
}),
104+
plugins: [
105+
/**
106+
* Create global constants which can be configured at compile time.
107+
*
108+
* Useful for allowing different behaviour between development builds and
109+
* release builds
110+
*
111+
* NODE_ENV should be production so that modules do not perform certain
112+
* development checks
113+
*/
114+
new webpack.EnvironmentPlugin({
115+
NODE_ENV: 'production',
116+
DEBUG_PROD: false,
117+
}),
118118

119-
new MiniCssExtractPlugin({
120-
filename: 'style.css',
121-
}),
119+
new MiniCssExtractPlugin({
120+
filename: 'style.css',
121+
}),
122122

123-
new BundleAnalyzerPlugin({
124-
analyzerMode: process.env.ANALYZE === 'true' ? 'server' : 'disabled',
125-
analyzerPort: 8889,
126-
}),
123+
new BundleAnalyzerPlugin({
124+
analyzerMode:
125+
process.env.ANALYZE === 'true' ? 'server' : 'disabled',
126+
analyzerPort: 8889,
127+
}),
127128

128-
new HtmlWebpackPlugin({
129-
filename: 'index.html',
130-
template: path.join(webpackPaths.srcRendererPath, 'index.ejs'),
131-
minify: {
132-
collapseWhitespace: true,
133-
removeAttributeQuotes: true,
134-
removeComments: true,
135-
},
136-
isBrowser: false,
137-
isDevelopment: process.env.NODE_ENV !== 'production',
138-
}),
129+
new HtmlWebpackPlugin({
130+
filename: 'index.html',
131+
template: path.join(webpackPaths.srcRendererPath, 'index.ejs'),
132+
minify: {
133+
collapseWhitespace: true,
134+
removeAttributeQuotes: true,
135+
removeComments: true,
136+
},
137+
isBrowser: false,
138+
isDevelopment: process.env.NODE_ENV !== 'production',
139+
}),
139140

140-
new webpack.DefinePlugin({
141-
'process.type': '"renderer"',
142-
}),
143-
],
141+
new webpack.DefinePlugin({
142+
'process.type': '"renderer"',
143+
}),
144+
],
144145
};
145146

146147
export default merge(baseConfig, configuration);

0 commit comments

Comments
 (0)