Skip to content

Commit

Permalink
初始化项目仓库
Browse files Browse the repository at this point in the history
  • Loading branch information
XUHAITAO19950518 committed Apr 15, 2021
0 parents commit 7fb027a
Show file tree
Hide file tree
Showing 97 changed files with 44,347 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
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
7 changes: 7 additions & 0 deletions .erb/configs/.eslintrc
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"
}
}
8 changes: 8 additions & 0 deletions .erb/configs/node-loader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = function () {
let nodeUrl = JSON.stringify(this.resourcePath);
if (process.env.NODE_ENV === 'production') {
nodeUrl = '__dirname +' + JSON.stringify(this.resourcePath.replace(__dirname, ''));
}
return 'try {global.process.dlopen(module, ' + nodeUrl + '); } catch(e) {' +
"throw new Error('Cannot open ' + " + nodeUrl + " + ': ' + e);}";
};
85 changes: 85 additions & 0 deletions .erb/configs/webpack.config.base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/**
* Base webpack config used across other specific configs
*/

import path from 'path';
import webpack from 'webpack';
import { dependencies as externals } from '../../src/package.json';

export default {
externals: [...Object.keys(externals || {})],

module: {
rules: [
{
test: /\.(js|ts|jsx|tsx)?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true
}
}
},
{
test: /\.global\.css$/,
use: [
{
loader: 'style-loader',
},
{
loader: 'css-loader',
options: {
},
},
],
},
{
test: /^((?!\.global).)*\.css$/,
use: [
{
loader: 'style-loader'
},
{
loader: 'css-loader',
options: {
modules: {
localIdentName: '[name]'
},
importLoaders: 2
}
}
]
},
{
test: /\.node$/,
loader: 'native-ext-loader',
options: {
// rewritePath: process.env.NODE_ENV === 'production' ? path.resolve(__dirname, '../../resources/app/dist') : undefined
basePath: process.env.NODE_ENV === 'production' ? ['../assets/slsdk'] : []
// name: "[path][name].[ext]",
}
}
]
},

output: {
path: path.join(__dirname, '../../src'),
// https://github.com/webpack/webpack/issues/1114
libraryTarget: 'commonjs2'
},

/**
* Determine the array of extensions that should be used to resolve modules.
*/
resolve: {
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],
modules: [path.join(__dirname, '../src'), 'node_modules']
},

plugins: [
new webpack.EnvironmentPlugin({
NODE_ENV: 'production'
})
]
};
4 changes: 4 additions & 0 deletions .erb/configs/webpack.config.eslint.js
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;
75 changes: 75 additions & 0 deletions .erb/configs/webpack.config.main.prod.babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/**
* 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 CheckNodeEnv from '../scripts/CheckNodeEnv';
import DeleteSourceMaps from '../scripts/DeleteSourceMaps';

CheckNodeEnv('production');
DeleteSourceMaps();

const devtoolsConfig = process.env.DEBUG_PROD === 'true' ? {
devtool: 'source-map'
} : {};

export default merge(baseConfig, {
...devtoolsConfig,

mode: 'production',

target: 'electron-main',

entry: './src/main.dev.ts',

output: {
path: path.join(__dirname, '../../'),
filename: './src/main.prod.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,
},
});
Loading

0 comments on commit 7fb027a

Please sign in to comment.