-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from sophiezzhou/main
release: trtc-education-electron v1.0.0
- Loading branch information
Showing
247 changed files
with
31,183 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"rules": { | ||
"no-console": "off", | ||
"global-require": "off", | ||
"import/no-dynamic-require": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/** | ||
* Base webpack config used across other specific configs | ||
*/ | ||
|
||
import path from 'path'; | ||
import os from 'os'; | ||
import webpack from 'webpack'; | ||
import webpackPaths from './webpack.paths.js'; | ||
import { dependencies as externals } from '../../build/app/package.json'; | ||
|
||
const targetPlatform = (function(){ | ||
let target = os.platform(); | ||
for (let i=0; i<process.argv.length; i++) { | ||
if (process.argv[i].includes('--target_platform=')) { | ||
target = process.argv[i].replace('--target_platform=', ''); | ||
break; | ||
} | ||
} | ||
if (!['win32', 'darwin'].includes) target = os.platform(); | ||
return target; | ||
})(); | ||
console.log('targetPlatform', targetPlatform); | ||
|
||
const getRewritePath = function() { | ||
console.log('getRewritePath:', process.env.NODE_ENV); | ||
let rewritePathString = ''; | ||
if (process.env.NODE_ENV === 'production') { | ||
rewritePathString = targetPlatform === 'win32' ? './resources' : '../Resources'; | ||
} else if (process.env.NODE_ENV === 'development') { | ||
rewritePathString = 'node_modules/trtc-electron-sdk/build/Release'; | ||
} | ||
return rewritePathString; | ||
}; | ||
|
||
export default { | ||
externals: [...Object.keys(externals || {})], | ||
|
||
module: { | ||
rules: [ | ||
{ test: /\.node$/, loader: 'native-ext-loader', options: { rewritePath: getRewritePath() } }, | ||
{ | ||
test: /\.[jt]sx?$/, | ||
exclude: /node_modules/, | ||
use: { | ||
loader: 'babel-loader', | ||
options: { | ||
cacheDirectory: true, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
|
||
output: { | ||
path: webpackPaths.srcPath, | ||
// https://github.com/webpack/webpack/issues/1114 | ||
library: { | ||
type: 'commonjs2', | ||
}, | ||
}, | ||
|
||
/** | ||
* Determine the array of extensions that should be used to resolve modules. | ||
*/ | ||
resolve: { | ||
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'], | ||
modules: [webpackPaths.srcPath, 'node_modules'], | ||
// fallback: { | ||
// fs: require.resolve('fs'), | ||
// }, | ||
}, | ||
|
||
plugins: [ | ||
new webpack.EnvironmentPlugin({ | ||
NODE_ENV: 'production', | ||
}), | ||
], | ||
// node: { | ||
// global: false, | ||
// __filename: false, | ||
// __dirname: false, | ||
// }, | ||
// target: 'node' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* eslint import/no-unresolved: off, import/no-self-import: off */ | ||
require('@babel/register'); | ||
|
||
module.exports = require('./webpack.config.renderer.dev.babel').default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/** | ||
* Webpack config for production electron main process | ||
*/ | ||
|
||
import path from 'path'; | ||
import webpack from 'webpack'; | ||
import { merge } from 'webpack-merge'; | ||
import TerserPlugin from 'terser-webpack-plugin'; | ||
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'; | ||
import baseConfig from './webpack.config.base'; | ||
import webpackPaths from './webpack.paths.js'; | ||
import checkNodeEnv from '../scripts/check-node-env'; | ||
import deleteSourceMaps from '../scripts/delete-source-maps'; | ||
|
||
checkNodeEnv('production'); | ||
deleteSourceMaps(); | ||
|
||
const devtoolsConfig = | ||
process.env.DEBUG_PROD === 'true' | ||
? { | ||
devtool: 'source-map', | ||
} | ||
: {}; | ||
|
||
export default merge(baseConfig, { | ||
...devtoolsConfig, | ||
|
||
mode: 'production', | ||
|
||
target: 'electron-main', | ||
|
||
entry: { | ||
main: path.join(webpackPaths.srcMainPath, 'main.ts'), | ||
preload: path.join(webpackPaths.srcMainPath, 'preload.js'), | ||
}, | ||
|
||
output: { | ||
path: webpackPaths.distMainPath, | ||
filename: '[name].js', | ||
}, | ||
|
||
optimization: { | ||
minimizer: [ | ||
new TerserPlugin({ | ||
parallel: true, | ||
}), | ||
], | ||
}, | ||
|
||
plugins: [ | ||
new BundleAnalyzerPlugin({ | ||
analyzerMode: | ||
process.env.OPEN_ANALYZER === 'true' ? 'server' : 'disabled', | ||
openAnalyzer: process.env.OPEN_ANALYZER === 'true', | ||
}), | ||
|
||
/** | ||
* Create global constants which can be configured at compile time. | ||
* | ||
* Useful for allowing different behaviour between development builds and | ||
* release builds | ||
* | ||
* NODE_ENV should be production so that modules do not perform certain | ||
* development checks | ||
*/ | ||
new webpack.EnvironmentPlugin({ | ||
NODE_ENV: 'production', | ||
DEBUG_PROD: false, | ||
START_MINIMIZED: false, | ||
}), | ||
], | ||
|
||
/** | ||
* Disables webpack processing of __dirname and __filename. | ||
* If you run the bundle in node.js it falls back to these values of node.js. | ||
* https://github.com/webpack/webpack/issues/2010 | ||
*/ | ||
node: { | ||
__dirname: false, | ||
__filename: false, | ||
}, | ||
}); |
Oops, something went wrong.