From ef07017a283059a1bee60411562e94aa7cce046e Mon Sep 17 00:00:00 2001 From: daixiaqing Date: Thu, 18 Mar 2021 10:53:03 +0800 Subject: [PATCH] perf: reduce size --- ams-web/config/webpack.build.config.js | 10 ++++++++++ ams-web/config/webpack.dev.config.js | 10 ++++++++++ ams-web/fetk.config.js | 9 --------- ams-web/package.json | 1 - job-web/config/webpack.build.config.js | 10 ++++++++++ job-web/config/webpack.dev.config.js | 10 ++++++++++ job-web/fetk.config.js | 9 --------- job-web/package.json | 3 +-- layout-web/config/registerApps.js | 1 - mon-web/config/webpack.build.config.js | 10 ++++++++++ mon-web/config/webpack.dev.config.js | 10 ++++++++++ mon-web/package.json | 4 +--- rdb-web/config/webpack.build.config.js | 10 ++++++++++ rdb-web/config/webpack.dev.config.js | 10 ++++++++++ rdb-web/fetk.config.js | 9 --------- rdb-web/package.json | 2 -- rdb-web/src/app.tsx | 2 -- 17 files changed, 82 insertions(+), 38 deletions(-) diff --git a/ams-web/config/webpack.build.config.js b/ams-web/config/webpack.build.config.js index 2206851..9d85858 100644 --- a/ams-web/config/webpack.build.config.js +++ b/ams-web/config/webpack.build.config.js @@ -14,6 +14,16 @@ module.exports = function getwebpackConfig(webpackConfig) { webpackConfig.output.filename = '[name]-[chunkhash].js'; webpackConfig.output.publicPath = `/${pkgJson.systemName}/`; + webpackConfig.externals = [ + /^react$/, + /^react\/lib.*/, + /^react-dom$/, + /.*react-dom.*/, + /^single-spa$/, + /^antd$/, + /^moment$/, + /^d3$/ + ]; webpackConfig.plugins = webpackConfig.plugins.filter((plugin) => { if (plugin instanceof HtmlWebpackPlugin || plugin instanceof MiniCssExtractPlugin) { diff --git a/ams-web/config/webpack.dev.config.js b/ams-web/config/webpack.dev.config.js index 139c9d4..f168b6e 100644 --- a/ams-web/config/webpack.dev.config.js +++ b/ams-web/config/webpack.dev.config.js @@ -18,6 +18,16 @@ module.exports = function getwebpackConfig(webpackConfig) { }); webpackConfig.output.publicPath = `http://0.0.0.0:${fetkJson.port}/${pkgJson.systemName}/`; webpackConfig.output.filename = '[name]-[chunkhash].js'; + webpackConfig.externals = [ + /^react$/, + /^react\/lib.*/, + /^react-dom$/, + /.*react-dom.*/, + /^single-spa$/, + /^antd$/, + /^moment$/, + /^d3$/ + ]; webpackConfig.plugins = webpackConfig.plugins.filter((plugin) => { if (plugin instanceof HtmlWebpackPlugin || plugin instanceof MiniCssExtractPlugin) { diff --git a/ams-web/fetk.config.js b/ams-web/fetk.config.js index c53de0a..8d8b324 100644 --- a/ams-web/fetk.config.js +++ b/ams-web/fetk.config.js @@ -15,15 +15,6 @@ module.exports = { eslintFix: false, hmr: false, port: 8002, - extraBabelPlugins: [ - [ - 'babel-plugin-import', - { - libraryName: 'antd', - style: true, - }, - ], - ], devServer: { inline: true, historyApiFallback: true, diff --git a/ams-web/package.json b/ams-web/package.json index 9d71c17..b5133d8 100644 --- a/ams-web/package.json +++ b/ams-web/package.json @@ -37,7 +37,6 @@ "react-sortable-hoc": "^1.8.3", "single-spa": "^5.5.5", "single-spa-react": "^2.14.0", - "three": "^0.56.0", "xlsx": "^0.16.6" }, "devDependencies": { diff --git a/job-web/config/webpack.build.config.js b/job-web/config/webpack.build.config.js index 2206851..9d85858 100644 --- a/job-web/config/webpack.build.config.js +++ b/job-web/config/webpack.build.config.js @@ -14,6 +14,16 @@ module.exports = function getwebpackConfig(webpackConfig) { webpackConfig.output.filename = '[name]-[chunkhash].js'; webpackConfig.output.publicPath = `/${pkgJson.systemName}/`; + webpackConfig.externals = [ + /^react$/, + /^react\/lib.*/, + /^react-dom$/, + /.*react-dom.*/, + /^single-spa$/, + /^antd$/, + /^moment$/, + /^d3$/ + ]; webpackConfig.plugins = webpackConfig.plugins.filter((plugin) => { if (plugin instanceof HtmlWebpackPlugin || plugin instanceof MiniCssExtractPlugin) { diff --git a/job-web/config/webpack.dev.config.js b/job-web/config/webpack.dev.config.js index ac6adad..fdac9b3 100644 --- a/job-web/config/webpack.dev.config.js +++ b/job-web/config/webpack.dev.config.js @@ -19,6 +19,16 @@ module.exports = function getwebpackConfig(webpackConfig) { }); webpackConfig.output.publicPath = `http://0.0.0.0:${fetkJson.port}/${pkgJson.systemName}/`; webpackConfig.output.filename = '[name]-[chunkhash].js'; + webpackConfig.externals = [ + /^react$/, + /^react\/lib.*/, + /^react-dom$/, + /.*react-dom.*/, + /^single-spa$/, + /^antd$/, + /^moment$/, + /^d3$/ + ]; webpackConfig.plugins = webpackConfig.plugins.filter((plugin) => { if (plugin instanceof HtmlWebpackPlugin || plugin instanceof MiniCssExtractPlugin) { diff --git a/job-web/fetk.config.js b/job-web/fetk.config.js index 19e2008..734f8a2 100644 --- a/job-web/fetk.config.js +++ b/job-web/fetk.config.js @@ -15,15 +15,6 @@ module.exports = { eslintFix: false, hmr: false, port: 8003, - extraBabelPlugins: [ - [ - 'babel-plugin-import', - { - libraryName: 'antd', - style: true, - }, - ], - ], devServer: { inline: true, historyApiFallback: true, diff --git a/job-web/package.json b/job-web/package.json index 82548ad..916adaf 100644 --- a/job-web/package.json +++ b/job-web/package.json @@ -48,8 +48,7 @@ "react-sortable-hoc": "^1.8.3", "react-syntax-highlighter": "^7.0.4", "single-spa": "^5.8.2", - "single-spa-react": "^2.14.0", - "three": "^0.56.0" + "single-spa-react": "^2.14.0" }, "devDependencies": { "@babel/core": "^7.5.5", diff --git a/layout-web/config/registerApps.js b/layout-web/config/registerApps.js index 8507364..de3ddd0 100644 --- a/layout-web/config/registerApps.js +++ b/layout-web/config/registerApps.js @@ -1,5 +1,4 @@ import * as singleSpa from 'single-spa'; -import React from 'react'; const customProps = { env: { diff --git a/mon-web/config/webpack.build.config.js b/mon-web/config/webpack.build.config.js index 76b6788..f4c4a2a 100644 --- a/mon-web/config/webpack.build.config.js +++ b/mon-web/config/webpack.build.config.js @@ -15,6 +15,16 @@ module.exports = function getwebpackConfig(webpackConfig) { webpackConfig.output.filename = '[name]-[chunkhash].js'; webpackConfig.output.publicPath = `/${pkgJson.systemName}/`; + webpackConfig.externals = [ + /^react$/, + /^react\/lib.*/, + /^react-dom$/, + /.*react-dom.*/, + /^single-spa$/, + /^antd$/, + /^moment$/, + /^d3$/ + ]; webpackConfig.plugins = webpackConfig.plugins.filter((plugin) => { if (plugin instanceof HtmlWebpackPlugin || plugin instanceof MiniCssExtractPlugin) { diff --git a/mon-web/config/webpack.dev.config.js b/mon-web/config/webpack.dev.config.js index 31cff60..a7a3001 100644 --- a/mon-web/config/webpack.dev.config.js +++ b/mon-web/config/webpack.dev.config.js @@ -17,6 +17,16 @@ module.exports = function getwebpackConfig(webpackConfig) { }); webpackConfig.output.publicPath = `http://0.0.0.0:${fetkJson.port}/${pkgJson.systemName}/`; webpackConfig.output.filename = '[name]-[chunkhash].js'; + webpackConfig.externals = [ + /^react$/, + /^react\/lib.*/, + /^react-dom$/, + /.*react-dom.*/, + /^single-spa$/, + /^antd$/, + /^moment$/, + /^d3$/ + ]; webpackConfig.plugins = webpackConfig.plugins.filter((plugin) => { if (plugin instanceof HtmlWebpackPlugin || plugin instanceof MiniCssExtractPlugin) { diff --git a/mon-web/package.json b/mon-web/package.json index 11d0dfd..eb18ec0 100644 --- a/mon-web/package.json +++ b/mon-web/package.json @@ -19,7 +19,6 @@ "@umijs/hooks": "^1.2.0", "ace-builds": "^1.4.11", "antd": "^3.26.0", - "axios": "^0.19.2", "bowser": "^2.11.0", "classnames": "^2.2.6", "color": "^3.1.0", @@ -48,8 +47,7 @@ "react-router-dom": "4.x", "react-sortable-hoc": "^1.8.3", "single-spa": "^5.5.5", - "single-spa-react": "^2.14.0", - "three": "^0.56.0" + "single-spa-react": "^2.14.0" }, "devDependencies": { "@babel/core": "^7.5.5", diff --git a/rdb-web/config/webpack.build.config.js b/rdb-web/config/webpack.build.config.js index 2a75a09..8acbf8f 100644 --- a/rdb-web/config/webpack.build.config.js +++ b/rdb-web/config/webpack.build.config.js @@ -14,6 +14,16 @@ module.exports = function getwebpackConfig(webpackConfig) { webpackConfig.output.filename = '[name]-[chunkhash].js'; webpackConfig.output.publicPath = `/${pkgJson.systemName}/`; + webpackConfig.externals = [ + /^react$/, + /^react\/lib.*/, + /^react-dom$/, + /.*react-dom.*/, + /^single-spa$/, + /^antd$/, + /^moment$/, + /^d3$/, + ]; webpackConfig.plugins = webpackConfig.plugins.filter((plugin) => { if (plugin instanceof HtmlWebpackPlugin || plugin instanceof MiniCssExtractPlugin) { diff --git a/rdb-web/config/webpack.dev.config.js b/rdb-web/config/webpack.dev.config.js index f3c47ce..ec1630a 100644 --- a/rdb-web/config/webpack.dev.config.js +++ b/rdb-web/config/webpack.dev.config.js @@ -18,6 +18,16 @@ module.exports = function getwebpackConfig(webpackConfig) { }); webpackConfig.output.publicPath = `http://0.0.0.0:${fetkJson.port}/${pkgJson.systemName}/`; webpackConfig.output.filename = '[name]-[chunkhash].js'; + webpackConfig.externals = [ + /^react$/, + /^react\/lib.*/, + /^react-dom$/, + /.*react-dom.*/, + /^single-spa$/, + /^antd$/, + /^moment$/, + /^d3$/, + ]; webpackConfig.plugins = webpackConfig.plugins.filter((plugin) => { if (plugin instanceof HtmlWebpackPlugin || plugin instanceof MiniCssExtractPlugin) { diff --git a/rdb-web/fetk.config.js b/rdb-web/fetk.config.js index ab316ea..d07393f 100644 --- a/rdb-web/fetk.config.js +++ b/rdb-web/fetk.config.js @@ -15,15 +15,6 @@ module.exports = { eslintFix: false, hmr: false, port: 8001, - extraBabelPlugins: [ - [ - 'babel-plugin-import', - { - libraryName: 'antd', - style: true, - }, - ], - ], devServer: { inline: true, historyApiFallback: true, diff --git a/rdb-web/package.json b/rdb-web/package.json index 30ee42f..b233c87 100644 --- a/rdb-web/package.json +++ b/rdb-web/package.json @@ -36,8 +36,6 @@ "react-sticky": "^6.0.3", "single-spa": "^5.8.0", "single-spa-react": "^2.14.0", - "three": "^0.56.0", - "whatwg-fetch": "^3.4.1", "xlsx": "^0.16.6" }, "devDependencies": { diff --git a/rdb-web/src/app.tsx b/rdb-web/src/app.tsx index 5a62f8c..95dda7d 100644 --- a/rdb-web/src/app.tsx +++ b/rdb-web/src/app.tsx @@ -10,8 +10,6 @@ import { IntlProvider } from 'react-intl'; import intlZhCN from './locales/zh'; import intlEnUS from './locales/en'; import { InjectIntlContext } from '@pkgs/hooks/useFormatMessage'; -import { Page403, Page404 } from '@pkgs/Exception'; -import { Login, Register } from '@pkgs/Auth'; import LayoutMain from '@pkgs/Layout/Main'; import { fetchManifest, getPathBySuffix, createStylesheetLink } from '@pkgs/utils'; import { systemName } from '@common/config';