diff --git a/.gitignore b/.gitignore index 77b0fbc58..2af64fca4 100644 --- a/.gitignore +++ b/.gitignore @@ -124,3 +124,6 @@ cypress/logs packages/*/dist bak/ + +# rollup 分析包体积结果 +stats.html diff --git a/README.md b/README.md index a6f2768ed..c294774cf 100644 --- a/README.md +++ b/README.md @@ -40,3 +40,8 @@ 注意合理使用 `peerDependencies` 和 `dependencies` ,不要重复打包一个第三方库 执行 `lerna add ...` 之后,需要重新 `lerna link` 建立内部连接 + +分析包体积 +- 命令行,进入某个 package ,如 `cd packages/editor` +- 执行 `yarn size-stats` ,等待执行完成 +- 结果会记录在 `packages/editor/stats.html` 用浏览器打开 diff --git a/build/create-rollup-config.js b/build/create-rollup-config.js index da905aa0f..c619c1002 100644 --- a/build/create-rollup-config.js +++ b/build/create-rollup-config.js @@ -5,13 +5,14 @@ import path from 'path' import peerDepsExternal from 'rollup-plugin-peer-deps-external' -// import { visualizer } from 'rollup-plugin-visualizer' +import { visualizer } from 'rollup-plugin-visualizer' import devConf from './config/dev' import prdConf from './config/prd' // 环境变量 const ENV = process.env.NODE_ENV || 'production' const IS_PRD = ENV === 'production' +const IS_SIZE_STATS = ENV === 'size_stats' /** * 生成单个 rollup 配置 @@ -32,6 +33,10 @@ function genSingleConfig(customConfig = {}) { // 打包结果不包含 peerDependencies ( 但 iife 格式不能用 ) insertedPlugins.push(peerDepsExternal()) } + if (IS_SIZE_STATS) { + // 分析包体积。运行之后可查看 package 下的 `stats.html` + insertedPlugins.push(visualizer()) + } return { input: input ? input : config.input, diff --git a/examples/batch-destroy.html b/examples/batch-destroy.html index ba8c81f34..ec80a9da0 100644 --- a/examples/batch-destroy.html +++ b/examples/batch-destroy.html @@ -20,7 +20,7 @@ #editor-text-area { border: 1px solid #ccc; height: 350px; - overflow: hidden; + /* overflow: hidden; */ } diff --git a/examples/headers.html b/examples/headers.html index 5d7ba3631..00008e834 100644 --- a/examples/headers.html +++ b/examples/headers.html @@ -21,7 +21,7 @@ #editor-text-area { border: 1px solid #ccc; height: 350px; - overflow: hidden; + /* overflow: hidden; */ /* z-index: 100; */ } diff --git a/examples/index.html b/examples/index.html index 57938e99d..67af7ed91 100644 --- a/examples/index.html +++ b/examples/index.html @@ -19,7 +19,7 @@ #editor-text-area { border: 1px solid #ccc; height: 350px; - overflow: hidden; + /* overflow: hidden; */ /* z-index: 100; */ } diff --git a/examples/upload-image.html b/examples/upload-image.html index ef740da26..dbb41a953 100644 --- a/examples/upload-image.html +++ b/examples/upload-image.html @@ -16,7 +16,7 @@ #editor-text-area { border: 1px solid #ccc; height: 550px; - overflow: hidden; + /* overflow: hidden; */ /* z-index: 100; */ } diff --git a/packages/basic-modules/package.json b/packages/basic-modules/package.json index 040e4485d..46c60cf2b 100644 --- a/packages/basic-modules/package.json +++ b/packages/basic-modules/package.json @@ -32,7 +32,8 @@ "test-c": "jest --coverage", "dev": "cross-env NODE_ENV=development rollup -c rollup.config.js", "dev-watch": "cross-env NODE_ENV=development rollup -c rollup.config.js -w", - "build": "cross-env NODE_ENV=production rollup -c rollup.config.js" + "build": "cross-env NODE_ENV=production rollup -c rollup.config.js", + "size-stats": "cross-env NODE_ENV=size_stats rollup -c rollup.config.js" }, "bugs": { "url": "https://github.com/wangeditor-team/we-2021/issues" @@ -51,4 +52,4 @@ "devDependencies": { "@types/is-url": "^1.2.29" } -} +} \ No newline at end of file diff --git a/packages/code-highlight/package.json b/packages/code-highlight/package.json index 447bba03b..95e4f2c76 100644 --- a/packages/code-highlight/package.json +++ b/packages/code-highlight/package.json @@ -32,7 +32,8 @@ "test-c": "jest --coverage", "dev": "cross-env NODE_ENV=development rollup -c rollup.config.js", "dev-watch": "cross-env NODE_ENV=development rollup -c rollup.config.js -w", - "build": "cross-env NODE_ENV=production rollup -c rollup.config.js" + "build": "cross-env NODE_ENV=production rollup -c rollup.config.js", + "size-stats": "cross-env NODE_ENV=size_stats rollup -c rollup.config.js" }, "bugs": { "url": "https://github.com/wangeditor-team/we-2021/issues" @@ -50,4 +51,4 @@ "devDependencies": { "@types/prismjs": "^1.16.5" } -} +} \ No newline at end of file diff --git a/packages/core/package.json b/packages/core/package.json index 81f798700..ca2871fd0 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -32,7 +32,8 @@ "test-c": "jest --coverage", "dev": "cross-env NODE_ENV=development rollup -c rollup.config.js", "dev-watch": "cross-env NODE_ENV=development rollup -c rollup.config.js -w", - "build": "cross-env NODE_ENV=production rollup -c rollup.config.js" + "build": "cross-env NODE_ENV=production rollup -c rollup.config.js", + "size-stats": "cross-env NODE_ENV=size_stats rollup -c rollup.config.js" }, "bugs": { "url": "https://github.com/wangeditor-team/we-2021/issues" @@ -55,4 +56,4 @@ "@types/is-hotkey": "^0.1.2", "@types/lodash-es": "^4.17.4" } -} +} \ No newline at end of file diff --git a/packages/editor/package.json b/packages/editor/package.json index 0bba31348..8805a8257 100644 --- a/packages/editor/package.json +++ b/packages/editor/package.json @@ -32,7 +32,8 @@ "test-c": "jest --coverage", "dev": "cross-env NODE_ENV=development rollup -c rollup.config.js", "dev-watch": "cross-env NODE_ENV=development rollup -c rollup.config.js -w", - "build": "cross-env NODE_ENV=production rollup -c rollup.config.js" + "build": "cross-env NODE_ENV=production rollup -c rollup.config.js", + "size-stats": "cross-env NODE_ENV=size_stats rollup -c rollup.config.js" }, "bugs": { "url": "https://github.com/wangeditor-team/we-2021/issues" @@ -52,4 +53,4 @@ "@uppy/core": "^1.19.1", "@uppy/xhr-upload": "^1.7.4" } -} +} \ No newline at end of file diff --git a/packages/editor/stats.html b/packages/editor/stats.html deleted file mode 100644 index 65e2cec6b..000000000 --- a/packages/editor/stats.html +++ /dev/null @@ -1,3279 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - diff --git a/packages/list-module/package.json b/packages/list-module/package.json index 14965876c..88a9b0cd6 100644 --- a/packages/list-module/package.json +++ b/packages/list-module/package.json @@ -32,7 +32,8 @@ "test-c": "jest --coverage", "dev": "cross-env NODE_ENV=development rollup -c rollup.config.js", "dev-watch": "cross-env NODE_ENV=development rollup -c rollup.config.js -w", - "build": "cross-env NODE_ENV=production rollup -c rollup.config.js" + "build": "cross-env NODE_ENV=production rollup -c rollup.config.js", + "size-stats": "cross-env NODE_ENV=size_stats rollup -c rollup.config.js" }, "bugs": { "url": "https://github.com/wangeditor-team/we-2021/issues" @@ -44,4 +45,4 @@ "slate": "^0.63.0", "snabbdom": "^3.0.1" } -} +} \ No newline at end of file diff --git a/packages/table-module/package.json b/packages/table-module/package.json index c02a355e2..6fb1bfca4 100644 --- a/packages/table-module/package.json +++ b/packages/table-module/package.json @@ -32,7 +32,8 @@ "test-c": "jest --coverage", "dev": "cross-env NODE_ENV=development rollup -c rollup.config.js", "dev-watch": "cross-env NODE_ENV=development rollup -c rollup.config.js -w", - "build": "cross-env NODE_ENV=production rollup -c rollup.config.js" + "build": "cross-env NODE_ENV=production rollup -c rollup.config.js", + "size-stats": "cross-env NODE_ENV=size_stats rollup -c rollup.config.js" }, "bugs": { "url": "https://github.com/wangeditor-team/we-2021/issues" @@ -47,4 +48,4 @@ "dependencies": { "lodash-es": "^4.17.21" } -} +} \ No newline at end of file diff --git a/packages/upload-image-module/package.json b/packages/upload-image-module/package.json index 8ca1db350..9bc2d968a 100644 --- a/packages/upload-image-module/package.json +++ b/packages/upload-image-module/package.json @@ -32,7 +32,8 @@ "test-c": "jest --coverage", "dev": "cross-env NODE_ENV=development rollup -c rollup.config.js", "dev-watch": "cross-env NODE_ENV=development rollup -c rollup.config.js -w", - "build": "cross-env NODE_ENV=production rollup -c rollup.config.js" + "build": "cross-env NODE_ENV=production rollup -c rollup.config.js", + "size-stats": "cross-env NODE_ENV=size_stats rollup -c rollup.config.js" }, "bugs": { "url": "https://github.com/wangeditor-team/we-2021/issues" @@ -50,4 +51,4 @@ "dependencies": { "lodash-es": "^4.17.21" } -} +} \ No newline at end of file diff --git a/packages/video-module/package.json b/packages/video-module/package.json index 30f96ed7b..e27a6a5a3 100644 --- a/packages/video-module/package.json +++ b/packages/video-module/package.json @@ -32,7 +32,8 @@ "test-c": "jest --coverage", "dev": "cross-env NODE_ENV=development rollup -c rollup.config.js", "dev-watch": "cross-env NODE_ENV=development rollup -c rollup.config.js -w", - "build": "cross-env NODE_ENV=production rollup -c rollup.config.js" + "build": "cross-env NODE_ENV=production rollup -c rollup.config.js", + "size-stats": "cross-env NODE_ENV=size_stats rollup -c rollup.config.js" }, "bugs": { "url": "https://github.com/wangeditor-team/we-2021/issues" @@ -44,4 +45,4 @@ "slate": "^0.63.0", "snabbdom": "^3.0.1" } -} +} \ No newline at end of file