Skip to content

Commit 6676ea2

Browse files
Initial commit
0 parents  commit 6676ea2

Some content is hidden

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

75 files changed

+32378
-0
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

.erb/configs/.eslintrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"rules": {
3+
"no-console": "off",
4+
"global-require": "off",
5+
"import/no-dynamic-require": "off"
6+
}
7+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* Base webpack config used across other specific configs
3+
*/
4+
5+
import webpack from 'webpack';
6+
import webpackPaths from './webpack.paths';
7+
import { dependencies as externals } from '../../release/app/package.json';
8+
9+
const configuration: webpack.Configuration = {
10+
externals: [...Object.keys(externals || {})],
11+
12+
stats: 'errors-only',
13+
14+
module: {
15+
rules: [
16+
{
17+
test: /\.[jt]sx?$/,
18+
exclude: /node_modules/,
19+
use: {
20+
loader: 'ts-loader',
21+
options: {
22+
// Remove this line to enable type checking in webpack builds
23+
transpileOnly: true,
24+
},
25+
},
26+
},
27+
],
28+
},
29+
30+
output: {
31+
path: webpackPaths.srcPath,
32+
// https://github.com/webpack/webpack/issues/1114
33+
library: {
34+
type: 'commonjs2',
35+
},
36+
},
37+
38+
/**
39+
* Determine the array of extensions that should be used to resolve modules.
40+
*/
41+
resolve: {
42+
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],
43+
modules: [webpackPaths.srcPath, 'node_modules'],
44+
},
45+
46+
plugins: [
47+
new webpack.EnvironmentPlugin({
48+
NODE_ENV: 'production',
49+
}),
50+
],
51+
};
52+
53+
export default configuration;
Lines changed: 3 additions & 0 deletions
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;
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/**
2+
* Webpack config for production electron main process
3+
*/
4+
5+
import path from 'path';
6+
import webpack from 'webpack';
7+
import { merge } from 'webpack-merge';
8+
import TerserPlugin from 'terser-webpack-plugin';
9+
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
10+
import baseConfig from './webpack.config.base';
11+
import webpackPaths from './webpack.paths';
12+
import checkNodeEnv from '../scripts/check-node-env';
13+
import deleteSourceMaps from '../scripts/delete-source-maps';
14+
15+
checkNodeEnv('production');
16+
deleteSourceMaps();
17+
18+
const devtoolsConfig =
19+
process.env.DEBUG_PROD === 'true'
20+
? {
21+
devtool: 'source-map',
22+
}
23+
: {};
24+
25+
const configuration: webpack.Configuration = {
26+
...devtoolsConfig,
27+
28+
mode: 'production',
29+
30+
target: 'electron-main',
31+
32+
entry: {
33+
main: path.join(webpackPaths.srcMainPath, 'main.ts'),
34+
preload: path.join(webpackPaths.srcMainPath, 'preload.ts'),
35+
},
36+
37+
output: {
38+
path: webpackPaths.distMainPath,
39+
filename: '[name].js',
40+
},
41+
42+
optimization: {
43+
minimizer: [
44+
new TerserPlugin({
45+
parallel: true,
46+
}),
47+
],
48+
},
49+
50+
plugins: [
51+
new BundleAnalyzerPlugin({
52+
analyzerMode: process.env.ANALYZE === 'true' ? 'server' : 'disabled',
53+
}),
54+
55+
/**
56+
* Create global constants which can be configured at compile time.
57+
*
58+
* Useful for allowing different behaviour between development builds and
59+
* release builds
60+
*
61+
* NODE_ENV should be production so that modules do not perform certain
62+
* development checks
63+
*/
64+
new webpack.EnvironmentPlugin({
65+
NODE_ENV: 'production',
66+
DEBUG_PROD: false,
67+
START_MINIMIZED: false,
68+
}),
69+
],
70+
71+
/**
72+
* Disables webpack processing of __dirname and __filename.
73+
* If you run the bundle in node.js it falls back to these values of node.js.
74+
* https://github.com/webpack/webpack/issues/2010
75+
*/
76+
node: {
77+
__dirname: false,
78+
__filename: false,
79+
},
80+
};
81+
82+
export default merge(baseConfig, configuration);
Lines changed: 68 additions & 0 deletions
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);
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/**
2+
* Builds the DLL for development electron renderer process
3+
*/
4+
5+
import webpack from 'webpack';
6+
import path from 'path';
7+
import { merge } from 'webpack-merge';
8+
import baseConfig from './webpack.config.base';
9+
import webpackPaths from './webpack.paths';
10+
import { dependencies } from '../../package.json';
11+
import checkNodeEnv from '../scripts/check-node-env';
12+
13+
checkNodeEnv('development');
14+
15+
const dist = webpackPaths.dllPath;
16+
17+
const configuration: webpack.Configuration = {
18+
context: webpackPaths.rootPath,
19+
20+
devtool: 'eval',
21+
22+
mode: 'development',
23+
24+
target: 'electron-renderer',
25+
26+
externals: ['fsevents', 'crypto-browserify'],
27+
28+
/**
29+
* Use `module` from `webpack.config.renderer.dev.js`
30+
*/
31+
module: require('./webpack.config.renderer.dev').default.module,
32+
33+
entry: {
34+
renderer: Object.keys(dependencies || {}),
35+
},
36+
37+
output: {
38+
path: dist,
39+
filename: '[name].dev.dll.js',
40+
library: {
41+
name: 'renderer',
42+
type: 'var',
43+
},
44+
},
45+
46+
plugins: [
47+
new webpack.DllPlugin({
48+
path: path.join(dist, '[name].json'),
49+
name: '[name]',
50+
}),
51+
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: 'development',
63+
}),
64+
65+
new webpack.LoaderOptionsPlugin({
66+
debug: true,
67+
options: {
68+
context: webpackPaths.srcPath,
69+
output: {
70+
path: webpackPaths.dllPath,
71+
},
72+
},
73+
}),
74+
],
75+
};
76+
77+
export default merge(baseConfig, configuration);

0 commit comments

Comments
 (0)