Skip to content

Commit

Permalink
feat: 完成 anaylze watch
Browse files Browse the repository at this point in the history
  • Loading branch information
谦男 committed Jun 26, 2024
1 parent 63f6d91 commit ebaa815
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
1 change: 0 additions & 1 deletion client/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ function App() {
// ref 用于保存Treemap实例
const treeMapRef = useRef(null);
const [chartData, setChartData] = useState('');

// toolTip展示使用
const [tooltipContent, setToolTipContent] = useState('');
const createModulesTree = (modules) => {
Expand Down
7 changes: 1 addition & 6 deletions client/mako.config.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
{
"devtool": "source-map",
"stats": { "modules": true },
"hash": true,
"analyze": {
"watch": true
}
"devtool": false
}
1 change: 0 additions & 1 deletion crates/mako/src/dev/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ impl DevServer {
let context = context.clone();
let txws = txws.clone();
let compile = compiler.clone();

let staticfile = hyper_staticfile_jsutf8::Static::new(
context.config.output.path.clone(),
);
Expand Down
8 changes: 8 additions & 0 deletions crates/mako/src/generate/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ pub struct Analyze {}

impl Analyze {
pub fn write_analyze(stats: &StatsJsonMap, context: Arc<Context>) -> Result<()> {
let analyze = context.config.analyze.clone().unwrap();
let mut is_watch = false;
if analyze.watch.is_some() && analyze.watch.unwrap() {
is_watch = true;
}

let stats_json = serde_json::to_string_pretty(&stats).unwrap();
let html_str = format!(
r#"<!DOCTYPE html>
Expand All @@ -23,12 +29,14 @@ impl Analyze {
<div id="root"></div>
<script>
window.chartData = {};
window.hmrWatch = {}
</script>
<script>{}</script>
</body>
</html>"#,
include_str!("../../../../client/dist/index.css"),
stats_json,
is_watch,
include_str!("../../../../client/dist/index.js").replace("</script>", "<\\/script>")
);
let report_path = context.config.output.path.join("report.html");
Expand Down

0 comments on commit ebaa815

Please sign in to comment.