Skip to content

Commit 9a91ad7

Browse files
committed
devop: 🔧 initial work for splitting builds
1 parent 94861b4 commit 9a91ad7

File tree

13 files changed

+525
-157
lines changed

13 files changed

+525
-157
lines changed

builds/defaultConfig.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
const imageminMozjpeg = require('imagemin-mozjpeg');
2+
const ImageminPlugin = require('imagemin-webpack-plugin').default;
3+
const webpack = require('webpack');
4+
const CopyWebpackPlugin = require('copy-webpack-plugin');
5+
const UglifyJS = require('uglify-es');
6+
const env_vars = require('../ENV_VARS');
7+
const allowedConnections = require('../connections');
8+
9+
const sourceMapsConfig = {
10+
filename: 'sourcemaps/[file].map'
11+
};
12+
13+
const webpackConfig = {
14+
devtool: false,
15+
node: {
16+
process: true
17+
},
18+
devServer: {
19+
https: true,
20+
host: 'localhost',
21+
hotOnly: true,
22+
port: 8080,
23+
headers: {
24+
'Strict-Transport-Security':
25+
'max-age=63072000; includeSubdomains; preload',
26+
'Content-Security-Policy':
27+
"font-src 'self' data: js.intercomcdn.com:443; media-src js.intercomcdn.com:443 'self'; default-src 'self' blob:; frame-src 'self' www.walletlink.org:443 connect.trezor.io:443 intercom-sheets.com:443; img-src 'self' downloads.intercomcdn.com:443 gifs.intercomcdn.com:443 js.intercomcdn.com:443 images.ctfassets.net static.intercomassets.com:443 nft.mewapi.io:443 mewcard.mewapi.io:443 img.mewapi.io:443 app.lokalise.com:443 data: blob: ; script-src 'unsafe-eval' 'unsafe-inline' blob: https:; style-src 'self' 'unsafe-inline' https:; object-src 'none'; connect-src " +
28+
allowedConnections.join(' ') +
29+
';',
30+
'X-Content-Type-Options': 'nosniff',
31+
'X-Frame-Options': 'DENY',
32+
'X-XSS-Protection': '1; mode=block',
33+
'Referrer-Policy': 'same-origin'
34+
}
35+
},
36+
plugins: [
37+
new webpack.SourceMapDevToolPlugin(sourceMapsConfig),
38+
new webpack.NormalModuleReplacementPlugin(/^any-promise$/, 'bluebird'),
39+
new ImageminPlugin({
40+
disable: process.env.NODE_ENV !== 'production',
41+
test: /\.(jpe?g|png|gif|svg)$/i,
42+
pngquant: {
43+
quality: '100'
44+
},
45+
plugins: [
46+
imageminMozjpeg({
47+
quality: 100,
48+
progressive: true
49+
})
50+
]
51+
}),
52+
new CopyWebpackPlugin({
53+
patterns: [
54+
{ from: 'security.txt', to: '.well-known/security.txt' },
55+
{
56+
from: 'public',
57+
transform: function (content, filePath) {
58+
if (filePath.split('.').pop() === ('js' || 'JS'))
59+
return UglifyJS.minify(content.toString()).code;
60+
return content;
61+
}
62+
}
63+
]
64+
}),
65+
new webpack.DefinePlugin(env_vars)
66+
],
67+
optimization: {
68+
splitChunks: {
69+
minSize: 1000000,
70+
maxSize: 20000000
71+
}
72+
}
73+
};
74+
75+
module.exports = { webpackConfig, sourceMapsConfig, env_vars };

builds/liveConfig.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const config = require('./defaultConfig');
2+
if (JSON.parse(config.env_vars.FULL_SOURCEMAPS) === 'false')
3+
config.sourceMapsConfig.exclude = /vendors.*.*/;
4+
5+
const exportObj = {
6+
publicPath: process.env.ROUTER_MODE === 'history' ? '/' : './',
7+
configureWebpack: config.webpackConfig,
8+
lintOnSave: process.env.NODE_ENV === 'production' ? 'error' : true,
9+
integrity: process.env.WEBPACK_INTEGRITY === 'false' ? false : true,
10+
pwa: {
11+
name: 'MyEtherWallet',
12+
workboxOptions: {
13+
importWorkboxFrom: 'local',
14+
skipWaiting: true,
15+
clientsClaim: true,
16+
navigateFallback: '/index.html'
17+
}
18+
},
19+
chainWebpack: config => {
20+
2;
21+
// GraphQL Loader
22+
config.module
23+
.rule('graphql')
24+
.test(/\.graphql$/)
25+
.use('graphql-tag/loader')
26+
.loader('graphql-tag/loader')
27+
.end();
28+
}
29+
};
30+
31+
module.exports = exportObj;

builds/offlineConfig.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const config = require('./defaultConfig');
2+
if (JSON.parse(config.env_vars.FULL_SOURCEMAPS) === 'false')
3+
config.sourceMapsConfig.exclude = /vendors.*.*/;
4+
const exportObj = {
5+
publicPath: './',
6+
configureWebpack: config.webpackConfig,
7+
lintOnSave: process.env.NODE_ENV === 'production' ? 'error' : true,
8+
integrity: process.env.WEBPACK_INTEGRITY === 'false' ? false : true,
9+
productionSourceMap: true,
10+
pages: {
11+
index: {
12+
entry: 'src/main/offlineMain.js',
13+
template: 'public/index.html',
14+
filename: 'index.html'
15+
}
16+
}
17+
};
18+
19+
module.exports = exportObj;

0 commit comments

Comments
 (0)