Skip to content

Commit 0253538

Browse files
committed
in the name of Uoosef Ghobadi 🕊
0 parents  commit 0253538

Some content is hidden

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

69 files changed

+20872
-0
lines changed

‎.editorconfig

+12
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

+7
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+
}
+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* Base webpack config used across other specific configs
3+
*/
4+
5+
import webpack from 'webpack';
6+
import TsconfigPathsPlugins from 'tsconfig-paths-webpack-plugin';
7+
import webpackPaths from './webpack.paths';
8+
import { dependencies as externals } from '../../release/app/package.json';
9+
10+
const configuration: webpack.Configuration = {
11+
externals: [...Object.keys(externals || {})],
12+
13+
stats: 'errors-only',
14+
15+
module: {
16+
rules: [
17+
{
18+
test: /\.[jt]sx?$/,
19+
exclude: /node_modules/,
20+
use: {
21+
loader: 'ts-loader',
22+
options: {
23+
// Remove this line to enable type checking in webpack builds
24+
transpileOnly: true,
25+
compilerOptions: {
26+
module: 'esnext',
27+
},
28+
},
29+
},
30+
},
31+
],
32+
},
33+
34+
output: {
35+
path: webpackPaths.srcPath,
36+
// https://github.com/webpack/webpack/issues/1114
37+
library: {
38+
type: 'commonjs2',
39+
},
40+
},
41+
42+
/**
43+
* Determine the array of extensions that should be used to resolve modules.
44+
*/
45+
resolve: {
46+
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],
47+
modules: [webpackPaths.srcPath, 'node_modules'],
48+
// There is no need to add aliases here, the paths in tsconfig get mirrored
49+
plugins: [new TsconfigPathsPlugins()],
50+
},
51+
52+
plugins: [
53+
new webpack.EnvironmentPlugin({
54+
NODE_ENV: 'production',
55+
}),
56+
],
57+
};
58+
59+
export default configuration;
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;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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 configuration: webpack.Configuration = {
19+
devtool: 'source-map',
20+
21+
mode: 'production',
22+
23+
target: 'electron-main',
24+
25+
entry: {
26+
main: path.join(webpackPaths.srcMainPath, 'main.ts'),
27+
preload: path.join(webpackPaths.srcMainPath, 'preload.ts'),
28+
},
29+
30+
output: {
31+
path: webpackPaths.distMainPath,
32+
filename: '[name].js',
33+
library: {
34+
type: 'umd',
35+
},
36+
},
37+
38+
optimization: {
39+
minimizer: [
40+
new TerserPlugin({
41+
parallel: true,
42+
}),
43+
],
44+
},
45+
46+
plugins: [
47+
new BundleAnalyzerPlugin({
48+
analyzerMode: process.env.ANALYZE === 'true' ? 'server' : 'disabled',
49+
analyzerPort: 8888,
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: 'production',
63+
DEBUG_PROD: false,
64+
START_MINIMIZED: false,
65+
}),
66+
67+
new webpack.DefinePlugin({
68+
'process.type': '"browser"',
69+
}),
70+
],
71+
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+
},
81+
};
82+
83+
export default merge(baseConfig, configuration);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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+
library: {
28+
type: 'umd',
29+
},
30+
},
31+
32+
plugins: [
33+
new BundleAnalyzerPlugin({
34+
analyzerMode: process.env.ANALYZE === 'true' ? 'server' : 'disabled',
35+
}),
36+
37+
/**
38+
* Create global constants which can be configured at compile time.
39+
*
40+
* Useful for allowing different behaviour between development builds and
41+
* release builds
42+
*
43+
* NODE_ENV should be production so that modules do not perform certain
44+
* development checks
45+
*
46+
* By default, use 'development' as NODE_ENV. This can be overriden with
47+
* 'staging', for example, by changing the ENV variables in the npm scripts
48+
*/
49+
new webpack.EnvironmentPlugin({
50+
NODE_ENV: 'development',
51+
}),
52+
53+
new webpack.LoaderOptionsPlugin({
54+
debug: true,
55+
}),
56+
],
57+
58+
/**
59+
* Disables webpack processing of __dirname and __filename.
60+
* If you run the bundle in node.js it falls back to these values of node.js.
61+
* https://github.com/webpack/webpack/issues/2010
62+
*/
63+
node: {
64+
__dirname: false,
65+
__filename: false,
66+
},
67+
68+
watch: true,
69+
};
70+
71+
export default merge(baseConfig, configuration);
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)