Skip to content

Commit

Permalink
chore: size stats
Browse files Browse the repository at this point in the history
  • Loading branch information
wangfupeng1988 committed Jun 30, 2021
1 parent ceb3f41 commit 5c042ef
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 3,300 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,6 @@ cypress/logs
packages/*/dist

bak/

# rollup 分析包体积结果
stats.html
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,8 @@
注意合理使用 `peerDependencies``dependencies` ,不要重复打包一个第三方库

执行 `lerna add ...` 之后,需要重新 `lerna link` 建立内部连接

分析包体积
- 命令行,进入某个 package ,如 `cd packages/editor`
- 执行 `yarn size-stats` ,等待执行完成
- 结果会记录在 `packages/editor/stats.html` 用浏览器打开
7 changes: 6 additions & 1 deletion build/create-rollup-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 配置
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion examples/batch-destroy.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#editor-text-area {
border: 1px solid #ccc;
height: 350px;
overflow: hidden;
/* overflow: hidden; */
}
</style>
<link href="../packages/editor/dist/css/style.css" rel="stylesheet">
Expand Down
2 changes: 1 addition & 1 deletion examples/headers.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#editor-text-area {
border: 1px solid #ccc;
height: 350px;
overflow: hidden;
/* overflow: hidden; */
/* z-index: 100; */
}
</style>
Expand Down
2 changes: 1 addition & 1 deletion examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#editor-text-area {
border: 1px solid #ccc;
height: 350px;
overflow: hidden;
/* overflow: hidden; */
/* z-index: 100; */
}

Expand Down
2 changes: 1 addition & 1 deletion examples/upload-image.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#editor-text-area {
border: 1px solid #ccc;
height: 550px;
overflow: hidden;
/* overflow: hidden; */
/* z-index: 100; */
}
</style>
Expand Down
5 changes: 3 additions & 2 deletions packages/basic-modules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -51,4 +52,4 @@
"devDependencies": {
"@types/is-url": "^1.2.29"
}
}
}
5 changes: 3 additions & 2 deletions packages/code-highlight/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -50,4 +51,4 @@
"devDependencies": {
"@types/prismjs": "^1.16.5"
}
}
}
5 changes: 3 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -55,4 +56,4 @@
"@types/is-hotkey": "^0.1.2",
"@types/lodash-es": "^4.17.4"
}
}
}
5 changes: 3 additions & 2 deletions packages/editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -52,4 +53,4 @@
"@uppy/core": "^1.19.1",
"@uppy/xhr-upload": "^1.7.4"
}
}
}
Loading

0 comments on commit 5c042ef

Please sign in to comment.