Skip to content

Commit

Permalink
add analysis, ref #1274 #1496
Browse files Browse the repository at this point in the history
  • Loading branch information
warmhug committed Jul 5, 2017
1 parent 472c35f commit 566b2e1
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "ant-design-analysis"]
path = ant-design-analysis
url = git@github.com:ant-design/ant-design-analysis.git
1 change: 1 addition & 0 deletions ant-design-analysis
Submodule ant-design-analysis added at c6bd70
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@
"stylelint-config-standard": "^16.0.0",
"svg-sprite-loader": "^0.3.1",
"typescript": "~2.3.0",
"typescript-babel-jest": "^1.0.1"
"typescript-babel-jest": "^1.0.1",
"webpack-visualizer-plugin": "^0.1.11"
},
"scripts": {
"lint": "npm run tslint && npm run srclint && npm run demolint && npm run stylelint && npm run applint",
Expand All @@ -144,15 +145,12 @@
"test:all": "./scripts/test-all.sh",
"authors": "git log --format='%aN <%aE>' | sort -u | grep -v 'users.noreply.github.com' > AUTHORS.txt",
"dist": "BABEL_ENV=dist antd-tools run dist",
"build": "BABEL_ENV=dist npm run dist",
"compile": "BABEL_ENV=dist antd-tools run compile",
"watch-tsc": "antd-tools run watch-tsc",
"clean": "antd-tools run clean",
"start": "concurrently \"bisheng start -c ./site/bisheng.desktop.config.js --no-livereload\" \"bisheng start -c ./site/bisheng.kitchen.config.js --no-livereload\"",
"demo": "bisheng start -c ./site/bisheng.kitchen.config.js",
"site": "concurrently \"bisheng build -c ./site/bisheng.desktop.config.js\" \"bisheng build -c ./site/bisheng.kitchen.config.js\" && node scripts/copy-app-res",
"pc": "bisheng start -c ./site/bisheng.desktop.config.js",
"mobile": "bisheng start -c ./site/bisheng.kitchen.config.js",
"analysis": "npm run dist && node ./scripts/analysis",
"deploy": "npm run clean && npm run site && bisheng gh-pages --push-only",
"pub": "BABEL_ENV=dist antd-tools run pub",
"rn-start": "node node_modules/react-native/local-cli/cli.js start",
Expand Down
20 changes: 20 additions & 0 deletions scripts/analysis.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* eslint-disable */
var fs = require('fs');
var path = require('path');
var analysisDir = path.join(__dirname,'../ant-design-analysis');

if(fs.existsSync(analysisDir)) {

console.log('generate versions.json for antd-mobile');

fs.readdir(analysisDir, function (err, files) {
var versions = [];
files.forEach(function (file) {
var mobileStats = file.match(/^antd-mobile@(.*).html$/);
if (mobileStats && mobileStats.length) {
versions.push(mobileStats[1]);
}
});
fs.writeFileSync(path.join(analysisDir, 'antd-mobile-versions.json'), JSON.stringify(versions));
});
}
9 changes: 8 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const getWebpackConfig = require('antd-tools/lib/getWebpackConfig');
const pxtorem = require('postcss-pxtorem');
const Visualizer = require('webpack-visualizer-plugin');
const configSvg = require('./svg.config');
const pkg = require('./package.json');

module.exports = function (webpackConfig) {
// fix `npm run dist` sourceMap error, do not know the reason
Expand All @@ -10,12 +12,17 @@ module.exports = function (webpackConfig) {
if (!Array.isArray(webpackConfig)) {
webpackConfig = [webpackConfig, webpackConfig];
}
webpackConfig.forEach((config) => {
webpackConfig.forEach((config, index) => {
config.postcss.push(pxtorem({
rootValue: 100,
propWhiteList: [],
}));
configSvg(config);
if (index === 0) {
config.plugins.push(new Visualizer({
filename: `../ant-design-analysis/${pkg.name}@${pkg.version}-stats.html`,
}));
}
});

return webpackConfig;
Expand Down

0 comments on commit 566b2e1

Please sign in to comment.