Skip to content

Commit bd134b4

Browse files
committed
support opening a file in browser
1 parent 712f825 commit bd134b4

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

README.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,21 @@ require('lasso').configure({
2323
]
2424
});
2525
```
26-
Creates lasso-analyze.html in your project directory.
27-
28-
29-
<p align="center">
30-
<img alt="lasso-analyzer" src="https://raw.githubusercontent.com/ajay2507/lasso-analyzer/master/example/lasso-analyze.png" width="512">
31-
</p>
3226

3327
## Usage as CLI ##
3428

3529
1. Bundled file is created under "build/static/" folder. Run the CLI as shown below
3630

3731
```bash
38-
lasso-analyzer <--bundle path--> <--outputFilename-->
32+
lasso-analyzer <--bundle path--> --output <--output filename-->
3933
```
4034
Creates outputFilename.html in your project structure.
4135

36+
```bash
37+
Options:
38+
--output To change the generated output filename. (default - lasso-analyze.html)
39+
```
40+
4241
For Example:
4342

4443
a. Analyze js bundle file.
@@ -60,6 +59,12 @@ open lasso-analyze.html
6059
```
6160
3. It shows you a treemap visualization as shown below.
6261

62+
## Output
63+
Creates lasso-analyze.html in your project directory.
64+
65+
<p align="center">
66+
<img alt="lasso-analyzer" src="https://raw.githubusercontent.com/ajay2507/lasso-analyzer/master/example/lasso-analyze.png" width="512">
67+
</p>
6368

6469
## Issues ##
6570
Free feel to create bug or propose improvements.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lasso-analyzer",
3-
"version": "1.4.0",
3+
"version": "1.4.1",
44
"description": "A tool to analyze the bundle created by Lasso",
55
"main": "src/index.js",
66
"bin": {
@@ -14,7 +14,8 @@
1414
},
1515
"dependencies": {
1616
"bundle-me": "^1.1.4",
17-
"lasso-unpack": "1.0.2"
17+
"lasso-unpack": "1.0.2",
18+
"opener": "^1.5.1"
1819
},
1920
"repository": {
2021
"type": "git",

src/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const fs = require('fs');
22
const path = require('path');
33
const lassoUnpack = require('lasso-unpack');
4+
const opener = require('opener');
45
const Tree = require('./tree');
56

67
function bundleAnalyzer(fileName, bundleName) {
@@ -20,6 +21,8 @@ function bundleAnalyzer(fileName, bundleName) {
2021
const html = generateHTML(tree);
2122
if (!bundleName) bundleName = "lasso-analyze";
2223
fs.writeFileSync(getOutputHTML(bundleName), html);
24+
// open the browser with generated html
25+
opener(getOutputHTML(bundleName));
2326
// clean files
2427
cleanFiles();
2528
};

src/lasso-analyzer-plugin.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ module.exports = (lasso, config) => {
3636
if (bundlePath) {
3737
lassoAnalyzer(bundlePath, bundleName);
3838
}
39-
4039
}
4140
});
4241
const endLog = `${borderX}` + `Created lasso-analyze.html in your project structure \n` +

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,11 @@ once@^1.3.0:
195195
dependencies:
196196
wrappy "1"
197197

198+
opener@^1.5.1:
199+
version "1.5.1"
200+
resolved "https://registry.yarnpkg.com/opener/-/opener-1.5.1.tgz#6d2f0e77f1a0af0032aca716c2c1fbb8e7e8abed"
201+
integrity sha512-goYSy5c2UXE4Ra1xixabeVh1guIX/ZV/YokJksb6q2lubWu6UbvPQ20p542/sFIll1nl8JnCyK9oBaOcCWXwvA==
202+
198203
path-is-absolute@^1.0.0:
199204
version "1.0.1"
200205
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"

0 commit comments

Comments
 (0)