diff --git a/build/webpack.base.config.js b/build/webpack.base.config.js index d7558800..82f9205c 100644 --- a/build/webpack.base.config.js +++ b/build/webpack.base.config.js @@ -2,8 +2,9 @@ * 公共配置 */ var path = require('path'); +var webpack = require('webpack'); function resolve (dir) { - return path.join(__dirname, '..', dir) + return path.join(__dirname, '..', dir); } module.exports = { @@ -63,5 +64,8 @@ module.exports = { 'vue': 'vue/dist/vue.esm.js', '@': resolve('src') } - } + }, + plugins: [ + new webpack.optimize.ModuleConcatenationPlugin() + ] }; diff --git a/build/webpack.dist.prod.config.js b/build/webpack.dist.prod.config.js index 6dd09752..2fd81172 100644 --- a/build/webpack.dist.prod.config.js +++ b/build/webpack.dist.prod.config.js @@ -2,6 +2,7 @@ var path = require('path'); var webpack = require('webpack'); var merge = require('webpack-merge'); var webpackBaseConfig = require('./webpack.base.config.js'); +var CompressionPlugin = require('compression-webpack-plugin'); process.env.NODE_ENV = 'production'; @@ -34,6 +35,13 @@ module.exports = merge(webpackBaseConfig, { compress: { warnings: false } + }), + new CompressionPlugin({ + asset: '[path].gz[query]', + algorithm: 'gzip', + test: /\.(js|css)$/, + threshold: 10240, + minRatio: 0.8 }) ] }); diff --git a/package-lock.json b/package-lock.json index 05039016..539117af 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "iview", - "version": "2.3.2", + "version": "2.4.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1887,6 +1887,25 @@ } } }, + "compression-webpack-plugin": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/compression-webpack-plugin/-/compression-webpack-plugin-1.0.0.tgz", + "integrity": "sha512-OPp+tvvMCd8FrJHDLG4v5EpP4Fe5w5uBNXOmc3K7SdBaK1FH+TGwtafG9GLgTI6c2WHIgDFt98T8qXwaXuyRnw==", + "requires": { + "async": "2.4.1", + "webpack-sources": "1.0.1" + }, + "dependencies": { + "async": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/async/-/async-2.4.1.tgz", + "integrity": "sha1-YqVrJ5yYoR0JhwlqAcw+6463u9c=", + "requires": { + "lodash": "4.17.4" + } + } + } + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -12302,8 +12321,7 @@ "lodash": { "version": "4.17.4", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", - "dev": true + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=" }, "lodash._baseassign": { "version": "3.2.0", @@ -14438,14 +14456,12 @@ "source-list-map": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.0.tgz", - "integrity": "sha512-I2UmuJSRr/T8jisiROLU3A3ltr+swpniSmNPI4Ml3ZCX6tVnDsuZzK7F2hl5jTqbZBWCEKlj5HRQiPExXLgE8A==", - "dev": true + "integrity": "sha512-I2UmuJSRr/T8jisiROLU3A3ltr+swpniSmNPI4Ml3ZCX6tVnDsuZzK7F2hl5jTqbZBWCEKlj5HRQiPExXLgE8A==" }, "source-map": { "version": "0.5.6", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", - "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=", - "dev": true + "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=" }, "source-map-support": { "version": "0.4.18", @@ -16272,7 +16288,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.0.1.tgz", "integrity": "sha512-05tMxipUCwHqYaVS8xc7sYPTly8PzXayRCB4dTxLhWTqlKUiwH6ezmEe0OSreL1c30LAuA3Zqmc+uEBUGFJDjw==", - "dev": true, "requires": { "source-list-map": "2.0.0", "source-map": "0.5.6" diff --git a/package.json b/package.json index 8f489201..6e10df54 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ }, "dependencies": { "async-validator": "^1.8.1", + "compression-webpack-plugin": "^1.0.0", "core-js": "^2.5.0", "deepmerge": "^1.5.1", "element-resize-detector": "^1.1.12",