Skip to content

Commit b513466

Browse files
committed
[chore] add webpack-stats-plugin. add resolve.modules to imporve webpack performance
1 parent 47b5fff commit b513466

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

build/webpack.build.config.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const autoprefixer = require('autoprefixer')
55
const px2rem = require('postcss-px2rem')
66
const fs = require('fs')
77
const path = require('path')
8+
const StatsWriterPlugin = require('webpack-stats-plugin').StatsWriterPlugin
89

910
const fileNameTransfer = fileName => fileName.match(/[A-Z][a-z]*/g).map((e) => e.toLowerCase()).join('-')
1011

@@ -85,7 +86,10 @@ module.exports = {
8586
new CleanPlugin(['lib'], {
8687
root: path.resolve(__dirname, '../'),
8788
})
88-
]
89+
],
90+
resolve: {
91+
modules: ['node_modules']
92+
}
8993
}
9094

9195
if(process.env.NODE_ENV === 'production') {
@@ -97,6 +101,13 @@ if(process.env.NODE_ENV === 'production') {
97101
warnings: false
98102
}
99103
}))
104+
// module.exports.plugins.push(new StatsWriterPlugin({
105+
// filename: 'stats.json',
106+
// transform: function(data, opts) {
107+
// let stats = opts.compiler.getStats().toJson({chunkModules: true})
108+
// return JSON.stringify(stats, null, 2)
109+
// }
110+
// }))
100111
}else {
101112
module.exports.devtool = 'eval-source-map'
102113
}

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
"vue-style-loader": "^2.0.5",
9191
"vue-template-compiler": "^2.2.6",
9292
"webpack": "^2.3.2",
93-
"webpack-dev-server": "^2.2.0"
93+
"webpack-dev-server": "^2.2.0",
94+
"webpack-stats-plugin": "^0.1.5"
9495
}
9596
}

yarn.lock

+4
Original file line numberDiff line numberDiff line change
@@ -6750,6 +6750,10 @@ webpack-sources@^0.2.3:
67506750
source-list-map "^1.1.1"
67516751
source-map "~0.5.3"
67526752

6753+
webpack-stats-plugin@^0.1.5:
6754+
version "0.1.5"
6755+
resolved "https://registry.yarnpkg.com/webpack-stats-plugin/-/webpack-stats-plugin-0.1.5.tgz#29e5f12ebfd53158d31d656a113ac1f7b86179d9"
6756+
67536757
webpack@^2.3.2:
67546758
version "2.3.2"
67556759
resolved "https://registry.yarnpkg.com/webpack/-/webpack-2.3.2.tgz#7d521e6f0777a3a58985c69425263fdfe977b458"

0 commit comments

Comments
 (0)