diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..a73a473c5c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "ant-design-analysis"] + path = ant-design-analysis + url = git@github.com:ant-design/ant-design-analysis.git diff --git a/ant-design-analysis b/ant-design-analysis new file mode 160000 index 0000000000..c6bd7009a7 --- /dev/null +++ b/ant-design-analysis @@ -0,0 +1 @@ +Subproject commit c6bd7009a770f33b38dcaf4a624a61c7aecaf34e diff --git a/package.json b/package.json index 38b37a14a7..2d9ce45af9 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/scripts/analysis.js b/scripts/analysis.js new file mode 100755 index 0000000000..f2cf46cc14 --- /dev/null +++ b/scripts/analysis.js @@ -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)); + }); +} diff --git a/webpack.config.js b/webpack.config.js index 3002f436da..b488eeb7d7 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -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 @@ -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;