ant-design/site/getExternalResources.js
Wei Zhu 7149d1fdff Add offline support (#10738)
* site: add offline support

* test update

* Revert "test update"

This reverts commit e1cb2fba80e44c7d4c248656a4d020cdfb323c0e.

* use reduce
2018-06-02 12:46:09 +08:00

20 lines
607 B
JavaScript

const glob = require('glob');
const fs = require('fs');
const { uniq } = require('lodash');
function getExternalResources() {
const files = glob.sync('{./{components,docs}/**/*.md,./site/**/*.{less,js,jsx}}');
const resources = files.reduce((acc, file) => {
const content = fs.readFileSync(file, 'utf-8');
const pattern = new RegExp('(https://.+\\.alipayobjects\\.com/.+\\.(png|jpg|svg)|)', 'mg');
const matches = content.match(pattern);
if (matches) {
acc = acc.concat(matches);
}
return acc;
}, []);
return uniq(resources);
}
module.exports = getExternalResources;