Skip to content

Commit

Permalink
Merge pull request #396 from appbaseio/build-optimization
Browse files Browse the repository at this point in the history
Build optimization
  • Loading branch information
lakhansamani committed Jul 28, 2020
2 parents 6ac0776 + a368544 commit 390fe46
Show file tree
Hide file tree
Showing 11 changed files with 1,280 additions and 71 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "3.4.6",
"version": "3.4.7",
"lerna": "2.11.0",
"command": {
"version": {
Expand Down
10 changes: 4 additions & 6 deletions packages/browser/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@appbaseio/dejavu-browser",
"description": "Dejavu monorepo data browser components",
"version": "3.4.6",
"version": "3.4.7",
"authors": [
"Anuj Shah <anujshah584@gmail.com>",
"Lakhan Samani <lakhan.m.samani@gmail.com> (https://github.com/lakhansamani)",
Expand All @@ -12,18 +12,16 @@
"main": "lib/index.js",
"module": "lib/index.es.js",
"peerDependencies": {
"@appbaseio/designkit": "^0.9.1",
"@appbaseio/reactivesearch": "^3.0.2",
"antd": "^3.10.4",
"@appbaseio/reactivesearch": "^3.11.7",
"antd": "^3.18.2",
"brace": "^0.11.1",
"lodash": "^4.17.11",
"lodash": "^4.17.10",
"moment": "^2.22.2",
"prop-types": "^15.6.2",
"react": "^16.5.1",
"react-ace": "^6.5.0",
"react-dom": "^16.5.1",
"react-emotion": "^9.2.12",
"react-feather": "^1.1.3",
"react-redux": "^5.0.7",
"react-router-dom": "^4.3.1",
"redux": "^3.7.2",
Expand Down
1 change: 0 additions & 1 deletion packages/browser/src/components/DataBrowser/DataBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ class DataBrowser extends Component<Props> {
headers: convertArrayToHeaders(headers),
};
}

const { appswitcher } = getUrlParams(window.location.search);
const hideAppSwitcher = appswitcher && appswitcher === 'false';

Expand Down
36 changes: 36 additions & 0 deletions packages/browser/src/components/Icons/Hash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React, { forwardRef } from 'react';
import PropTypes from 'prop-types';

const Hash = forwardRef(
({ color = 'currentColor', size = 24, ...rest }, ref) => {
return (
<svg
ref={ref}
xmlns="http://www.w3.org/2000/svg"
width={size}
height={size}
viewBox="0 0 24 24"
fill="none"
stroke={color}
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
{...rest}
>
<line x1="4" y1="9" x2="20" y2="9" />
<line x1="4" y1="15" x2="20" y2="15" />
<line x1="10" y1="3" x2="8" y2="21" />
<line x1="16" y1="3" x2="14" y2="21" />
</svg>
);
},
);

Hash.propTypes = {
color: PropTypes.string,
size: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
};

Hash.displayName = 'Hash';

export default Hash;
34 changes: 34 additions & 0 deletions packages/browser/src/components/Icons/Toggle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React, { forwardRef } from 'react';
import PropTypes from 'prop-types';

const ToggleRight = forwardRef(
({ color = 'currentColor', size = 24, ...rest }, ref) => {
return (
<svg
ref={ref}
xmlns="http://www.w3.org/2000/svg"
width={size}
height={size}
viewBox="0 0 24 24"
fill="none"
stroke={color}
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
{...rest}
>
<rect x="1" y="5" width="22" height="14" rx="7" ry="7" />
<circle cx="16" cy="12" r="3" />
</svg>
);
},
);

ToggleRight.propTypes = {
color: PropTypes.string,
size: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
};

ToggleRight.displayName = 'ToggleRight';

export default ToggleRight;
4 changes: 2 additions & 2 deletions packages/browser/src/components/MappingsIcon/MappingsIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import React from 'react';
import { object } from 'prop-types';
import { Icon } from 'antd';
import Hash from 'react-feather/dist/icons/hash';
import Toggle from 'react-feather/dist/icons/toggle-right';
import Hash from '../Icons/Hash';
import Toggle from '../Icons/Toggle';

type Props = {
mapping: object,
Expand Down
5 changes: 4 additions & 1 deletion packages/browser/src/sagas/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ function* handleConnectApp({ appname, url, headers }) {
const appUrl = trimUrl(url);
try {
yield put(clearError());
yield call(testConnection, appname, appUrl, headers);
const newHeaders =
headers &&
headers.filter(item => item.key.trim() && item.value.trim());
yield call(testConnection, appname, appUrl, newHeaders);
yield put(connectAppSuccess(appname, appUrl));
} catch (error) {
yield put(connectAppFailure());
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ const getCustomHeaders = appname => {
const currentApp = pastApps.find(item => item.appname === appname);

if (currentApp && currentApp.headers) {
return currentApp.headers;
return currentApp.headers.filter(item => item.key && item.value);
}
}

Expand Down
19 changes: 11 additions & 8 deletions packages/dejavu-main/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "dejavu-main",
"description": "Dejavu main module",
"version": "3.4.6",
"version": "3.4.7",
"authors": [
"Anuj Shah <anujshah584@gmail.com>",
"Lakhan Samani <lakhan.m.samani@gmail.com> (https://github.com/lakhansamani)",
Expand All @@ -12,18 +12,18 @@
"main": "lib/index.js",
"module": "lib/index.es.js",
"peerDependencies": {
"react": "^16.5.1",
"react-dom": "^16.5.1"
"react": "^16.13.1",
"react-dom": "^16.13.1"
},
"dependencies": {
"@appbaseio/dejavu-browser": "^3.4.6",
"@appbaseio/designkit": "^0.9.1",
"@appbaseio/reactivesearch": "^3.0.2",
"@appbaseio/dejavu-browser": "^3.4.7",
"@appbaseio/designkit": "^0.9.12",
"@appbaseio/reactivesearch": "^3.11.7",
"@divyanshu013/media": "^1.0.0",
"@fortawesome/fontawesome-svg-core": "^1.2.27",
"@fortawesome/free-solid-svg-icons": "^5.12.1",
"@fortawesome/react-fontawesome": "^0.1.8",
"antd": "^3.10.4",
"antd": "^3.18.2",
"appbase-js": "^4.0.2-beta.2",
"brace": "^0.11.1",
"codesandbox": "1.3.5",
Expand All @@ -44,7 +44,6 @@
"react-element-to-jsx-string": "^14.0.2",
"react-emotion": "^9.2.12",
"react-expand-collapse": "^0.2.0",
"react-feather": "^1.1.3",
"react-joyride": "^2.0.0-15",
"react-json-editor-ajrm": "^2.5.8",
"react-redux": "^5.0.7",
Expand All @@ -60,12 +59,16 @@
},
"devDependencies": {
"clean-webpack-plugin": "^1.0.0",
"compression-webpack-plugin": "^4.0.0",
"copy-webpack-plugin": "^4.0.0",
"favicons-webpack-plugin": "^0.0.9",
"html-webpack-harddisk-plugin": "^1.0.1",
"html-webpack-plugin": "^3.2.0",
"mini-css-extract-plugin": "^0.9.0",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"terser-webpack-plugin": "^3.0.8",
"webpack": "^4.19.0",
"webpack-bundle-analyzer": "^3.0.2",
"webpack-cli": "^3.1.0",
Expand Down
66 changes: 57 additions & 9 deletions packages/dejavu-main/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ const CleanWebpackPlugin = require('clean-webpack-plugin');
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const WriteWebPackPlugin = require('write-file-webpack-plugin');
const TerserJSPlugin = require('terser-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');

const { NODE_ENV } = process.env;

const isDevelopment = NODE_ENV === 'development';

const plugins = [
// Ignore all locale files of moment.js
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
Expand All @@ -30,18 +36,63 @@ const plugins = [
new WriteWebPackPlugin(),
];

const isDevelopment = NODE_ENV === 'development';
if (!isDevelopment) {
plugins.push(
new MiniCssExtractPlugin({
filename: '[name].[contenthash:8].css',
chunkFilename: '[name].[contenthash:8].css',
}),
);
plugins.push(
new CompressionPlugin({
filename: '[path].gz[query]',
algorithm: 'gzip',
test: /\.js$|\.css$|\.html$/,
threshold: 10240,
minRatio: 0.8,
}),
);
plugins.push(
new CompressionPlugin({
filename: '[path].br[query]',
algorithm: 'brotliCompress',
test: /\.(js|css|html|svg)$/,
compressionOptions: {
level: 11,
},
threshold: 10240,
minRatio: 0.8,
}),
);
}

module.exports = {
entry: [path.resolve(__dirname, 'app/src/index.js')],
output: {
path: path.resolve(__dirname, 'dist/app'),
publicPath: '/',
filename: isDevelopment ? '[name].js' : '[name].[chunkhash:8].js',
filename: isDevelopment ? '[name].js' : '[name].[contenthash:8].js',
chunkFilename: isDevelopment
? '[name].bundle.js'
: '[name].[contenthash:8].js',
},
optimization: {
moduleIds: 'hashed',
runtimeChunk: {
name: 'manifest',
},
minimizer: isDevelopment
? []
: [new TerserJSPlugin({}), new OptimizeCSSAssetsPlugin({})],
splitChunks: {
chunks: 'initial',
cacheGroups: {
// Splitting React into a different bundle
common: {
test: /[\\/]node_modules[\\/](react|react-dom|antd)[\\/]/,
name: 'common',
chunks: 'all',
},
},
},
},
plugins,
Expand All @@ -57,12 +108,9 @@ module.exports = {
{
test: /\.css$/,
use: [
{
loader: 'style-loader',
options: {
insertAt: 'top',
},
},
isDevelopment
? 'style-loader'
: MiniCssExtractPlugin.loader,
'css-loader',
],
},
Expand Down
Loading

0 comments on commit 390fe46

Please sign in to comment.