Skip to content

Commit

Permalink
docs: add bundle analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Aug 2, 2017
1 parent ba1ae16 commit 6e70828
Show file tree
Hide file tree
Showing 5 changed files with 967 additions and 19 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -6,6 +6,10 @@

Modular import plugin for TypeScript, compatible with antd, antd-mobile and so on.

webpack template `./webpack.config.js`, run: `npm start` to see the bundle analyzer.

![bundle-analyzer](./bundle.png)

# Why use this

transform such code:
Expand Down
Binary file added bundle.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions package.json
Expand Up @@ -13,7 +13,7 @@
"cover": "rm -rf ./coverage ./.nyc_output && nyc --reporter=html --reporter=lcov --exclude=node_modules --exclude=test mocha",
"lint": "tslint -c ./tslint.json ./src/**/*.ts & standard \"test/*.js\" \"./*.js\"",
"prepare": "npm run build",
"start": "rm -rf dist && NODE_ENV=production webpack --optimize-minimize",
"start": "rm -rf dist && NODE_ENV=production webpack",
"test": "mocha",
"watch": "tsc -p ./src/tsconfig.json -w --diagnostics"
},
Expand All @@ -38,17 +38,21 @@
"antd": "^2.12.3",
"chai": "^4.1.0",
"coveralls": "^2.13.1",
"css-loader": "^0.28.4",
"extract-text-webpack-plugin": "^3.0.0",
"lodash": "^4.17.4",
"mocha": "^3.5.0",
"nyc": "^11.1.0",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"standard": "^10.0.2",
"style-loader": "^0.18.2",
"ts-loader": "^2.3.2",
"ts-node": "^3.3.0",
"tslint": "^5.5.0",
"tslint-eslint-rules": "^4.1.1",
"webpack": "^3.4.1"
"webpack": "^3.4.1",
"webpack-bundle-analyzer": "^2.8.3"
},
"dependencies": {
"tslib": "^1.7.1",
Expand Down
40 changes: 39 additions & 1 deletion webpack.config.js
@@ -1,8 +1,14 @@
const { resolve } = require('path')
const webpack = require('webpack')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const antdImportPluginFactory = require('./index')

const antdImportPlugin = antdImportPluginFactory({ style: false })
const antdImportPlugin = antdImportPluginFactory({ style: 'css' })

const Extralib = new ExtractTextPlugin({
filename: 'lib.css'
})

module.exports = {
entry: {
Expand Down Expand Up @@ -30,13 +36,45 @@ module.exports = {
}
},
exclude: /node_modules/
},
{
test: /\.css$/,
loader: Extralib.extract({
fallback: 'style-loader',
use: [
'css-loader?minimize'
]
})
}
]
},

plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}),

Extralib,

new webpack.HashedModuleIdsPlugin(),

new webpack.optimize.UglifyJsPlugin({
mangle: {
screw_ie8: true
},
compress: {
screw_ie8: true,
dead_code: true,
warnings: false
},
beautify: false,
sourceMap: false,
comments: false
}),

new BundleAnalyzerPlugin({
analyzerMode: 'static',
reportFilename: './report.html'
})
]
}

0 comments on commit 6e70828

Please sign in to comment.