-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
502073d
commit 5cdca70
Showing
4 changed files
with
83 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,38 @@ | ||
const glob = require('glob'); | ||
const fs = require("fs"); | ||
const glob = require("glob"); | ||
const { calculate } = require("gzipped"); | ||
const defaultPath = "./dist/*.js"; | ||
|
||
module.exports = { | ||
routes: { | ||
get: { | ||
'js-size': async (req, res) => { | ||
const config = req.app.locals.config; | ||
routes: { | ||
get: { | ||
"js-size": async (req, res) => { | ||
const config = req.app.locals.config; | ||
|
||
const pattern = config.jsBudgetPath || "./dist/*.js"; | ||
const pattern = config.jsBudgetPath || defaultPath; | ||
|
||
const g = glob(pattern, { stat: true }, (er, files) => { }); | ||
const g = glob(pattern, { stat: true }, (er, files) => {}); | ||
|
||
let size = 0; | ||
g.on('stat', function (path, stat) { | ||
size += stat.size; | ||
}) | ||
g.on('end', () => { | ||
res.send({ size }); | ||
}); | ||
} | ||
} | ||
let size = 0; | ||
g.on("stat", (path, stat) => { | ||
size += stat.size; | ||
}); | ||
g.on("end", () => { | ||
res.send({ size }); | ||
}); | ||
}, | ||
gzipped: async (req, rest) => { | ||
/*merge with above endpoint*/ | ||
const config = req.app.locals.config; | ||
|
||
const pattern = config.jsBudgetPath || defaultPath; | ||
|
||
const g = glob(pattern, { stat: true }, (er, files) => {}); | ||
|
||
g.on("stat", path => { | ||
calculate(fs.createReadStream(path), console.log); | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters