Skip to content

Commit a417a12

Browse files
committed
Use findImports to find external dependencies to decrease webpack bundle size
1 parent 3c4bc93 commit a417a12

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

examples/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ module.exports = {
6565
},
6666
plugins: [
6767
new webpack.LoaderOptionsPlugin({
68-
debug: true,
68+
debug: true
6969
}),
7070
new webpack.NamedModulesPlugin(),
7171
new webpack.NoEmitOnErrorsPlugin(),

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@
7878
"eslint-plugin-jsx-a11y": "~2.2.3",
7979
"eslint-plugin-react": "~6.10.0",
8080
"extract-text-webpack-plugin": "^2.0.0-rc.3",
81-
"file-loader": "^0.10.0",
81+
"file-loader": "~0.10.0",
82+
"find-imports": "~0.5.1",
8283
"html-webpack-plugin": "~2.28.0",
8384
"http-server": "~0.9.0",
8485
"nib": "~1.1.2",
@@ -90,7 +91,7 @@
9091
"stylus-loader": "~2.4.0",
9192
"tap": "~10.1.1",
9293
"trendmicro-ui": "~0.2.0",
93-
"url-loader": "^0.5.7",
94+
"url-loader": "~0.5.7",
9495
"webpack": "~2.2.1",
9596
"webpack-dev-server": "~2.3.0"
9697
}

webpack.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ var pkg = require('./package.json');
22
var path = require('path');
33
var webpack = require('webpack');
44
var ExtractTextPlugin = require('extract-text-webpack-plugin');
5+
var findImports = require('find-imports');
56
var stylusLoader = require('stylus-loader');
67
var nib = require('nib');
78
var publicname = pkg.name.replace(/^@\w+\//, ''); // Strip out "@trendmicro/" from package name
@@ -22,6 +23,7 @@ module.exports = {
2223
libraryTarget: 'commonjs2'
2324
},
2425
externals: []
26+
.concat(findImports(['src/**/*.{js,jsx}'], { flatten: true }))
2527
.concat(Object.keys(pkg.peerDependencies))
2628
.concat(Object.keys(pkg.dependencies)),
2729
module: {

0 commit comments

Comments
 (0)