Skip to content

Commit b6f5610

Browse files
authored
Upgrade erb (#9)
1 parent fb3bf75 commit b6f5610

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+10385
-10989
lines changed

.erb/configs/webpack.config.base.js renamed to .erb/configs/webpack.config.base.ts

+16-9
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,45 @@
22
* Base webpack config used across other specific configs
33
*/
44

5-
import path from 'path';
65
import webpack from 'webpack';
7-
import { dependencies as externals } from '../../src/package.json';
6+
import webpackPaths from './webpack.paths';
7+
import { dependencies as externals } from '../../release/app/package.json';
88

9-
export default {
9+
const configuration: webpack.Configuration = {
1010
externals: [...Object.keys(externals || {})],
1111

12+
stats: 'errors-only',
13+
1214
module: {
1315
rules: [
1416
{
15-
test: /\.tsx?$/,
17+
test: /\.[jt]sx?$/,
1618
exclude: /node_modules/,
1719
use: {
18-
loader: 'babel-loader',
20+
loader: 'ts-loader',
1921
options: {
20-
cacheDirectory: true,
22+
// Remove this line to enable type checking in webpack builds
23+
transpileOnly: true,
2124
},
2225
},
2326
},
2427
],
2528
},
2629

2730
output: {
28-
path: path.join(__dirname, '../../src'),
31+
path: webpackPaths.srcPath,
2932
// https://github.com/webpack/webpack/issues/1114
30-
libraryTarget: 'commonjs2',
33+
library: {
34+
type: 'commonjs2',
35+
},
3136
},
3237

3338
/**
3439
* Determine the array of extensions that should be used to resolve modules.
3540
*/
3641
resolve: {
3742
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],
38-
modules: [path.join(__dirname, '../../src'), 'node_modules'],
43+
modules: [webpackPaths.srcPath, 'node_modules'],
3944
},
4045

4146
plugins: [
@@ -44,3 +49,5 @@ export default {
4449
}),
4550
],
4651
};
52+
53+
export default configuration;

.erb/configs/webpack.config.eslint.js

-4
This file was deleted.

.erb/configs/webpack.config.eslint.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/* eslint import/no-unresolved: off, import/no-self-import: off */
2+
3+
module.exports = require('./webpack.config.renderer.dev').default;

.erb/configs/webpack.config.main.prod.babel.js renamed to .erb/configs/webpack.config.main.prod.ts

+18-18
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,41 @@ import { merge } from 'webpack-merge';
88
import TerserPlugin from 'terser-webpack-plugin';
99
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
1010
import baseConfig from './webpack.config.base';
11-
import CheckNodeEnv from '../scripts/CheckNodeEnv';
12-
import DeleteSourceMaps from '../scripts/DeleteSourceMaps';
11+
import webpackPaths from './webpack.paths';
12+
import checkNodeEnv from '../scripts/check-node-env';
13+
import deleteSourceMaps from '../scripts/delete-source-maps';
1314

14-
CheckNodeEnv('production');
15-
DeleteSourceMaps();
15+
checkNodeEnv('production');
16+
deleteSourceMaps();
1617

17-
const devtoolsConfig = process.env.DEBUG_PROD === 'true' ? {
18-
devtool: 'source-map'
19-
} : {};
20-
21-
export default merge(baseConfig, {
22-
...devtoolsConfig,
18+
const configuration: webpack.Configuration = {
19+
devtool: 'source-map',
2320

2421
mode: 'production',
2522

2623
target: 'electron-main',
2724

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

3030
output: {
31-
path: path.join(__dirname, '../../'),
32-
filename: './src/main.prod.js',
31+
path: webpackPaths.distMainPath,
32+
filename: '[name].js',
3333
},
3434

3535
optimization: {
3636
minimizer: [
3737
new TerserPlugin({
3838
parallel: true,
3939
}),
40-
]
40+
],
4141
},
4242

4343
plugins: [
4444
new BundleAnalyzerPlugin({
45-
analyzerMode:
46-
process.env.OPEN_ANALYZER === 'true' ? 'server' : 'disabled',
47-
openAnalyzer: process.env.OPEN_ANALYZER === 'true',
45+
analyzerMode: process.env.ANALYZE === 'true' ? 'server' : 'disabled',
4846
}),
4947

5048
/**
@@ -72,4 +70,6 @@ export default merge(baseConfig, {
7270
__dirname: false,
7371
__filename: false,
7472
},
75-
});
73+
};
74+
75+
export default merge(baseConfig, configuration);
+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import path from 'path';
2+
import webpack from 'webpack';
3+
import { merge } from 'webpack-merge';
4+
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
5+
import baseConfig from './webpack.config.base';
6+
import webpackPaths from './webpack.paths';
7+
import checkNodeEnv from '../scripts/check-node-env';
8+
9+
// When an ESLint server is running, we can't set the NODE_ENV so we'll check if it's
10+
// at the dev webpack config is not accidentally run in a production environment
11+
if (process.env.NODE_ENV === 'production') {
12+
checkNodeEnv('development');
13+
}
14+
15+
const configuration: webpack.Configuration = {
16+
devtool: 'inline-source-map',
17+
18+
mode: 'development',
19+
20+
target: 'electron-preload',
21+
22+
entry: path.join(webpackPaths.srcMainPath, 'preload.ts'),
23+
24+
output: {
25+
path: webpackPaths.dllPath,
26+
filename: 'preload.js',
27+
},
28+
29+
plugins: [
30+
new BundleAnalyzerPlugin({
31+
analyzerMode: process.env.ANALYZE === 'true' ? 'server' : 'disabled',
32+
}),
33+
34+
/**
35+
* Create global constants which can be configured at compile time.
36+
*
37+
* Useful for allowing different behaviour between development builds and
38+
* release builds
39+
*
40+
* NODE_ENV should be production so that modules do not perform certain
41+
* development checks
42+
*
43+
* By default, use 'development' as NODE_ENV. This can be overriden with
44+
* 'staging', for example, by changing the ENV variables in the npm scripts
45+
*/
46+
new webpack.EnvironmentPlugin({
47+
NODE_ENV: 'development',
48+
}),
49+
50+
new webpack.LoaderOptionsPlugin({
51+
debug: true,
52+
}),
53+
],
54+
55+
/**
56+
* Disables webpack processing of __dirname and __filename.
57+
* If you run the bundle in node.js it falls back to these values of node.js.
58+
* https://github.com/webpack/webpack/issues/2010
59+
*/
60+
node: {
61+
__dirname: false,
62+
__filename: false,
63+
},
64+
65+
watch: true,
66+
};
67+
68+
export default merge(baseConfig, configuration);

0 commit comments

Comments
 (0)