Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit ac32b14

Browse files
committed
feat: add BundleAnalyzerPlugin to webpack config
1 parent 7f6b296 commit ac32b14

File tree

6 files changed

+42
-1
lines changed

6 files changed

+42
-1
lines changed

Diff for: dependencyManager.js

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ function addDependency(deps, name, version, force) {
5959
function getRequiredDeps(packageJson) {
6060
let deps = {
6161
"webpack": "~3.0.0",
62+
"webpack-bundle-analyzer": "^2.8.2",
6263
"webpack-sources": "~1.0.1",
6364
"copy-webpack-plugin": "~4.0.1",
6465
"raw-loader": "~0.5.1",

Diff for: prepublish/common/imports.js

+1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ const nsWebpack = require("nativescript-dev-webpack");
55
const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target");
66
const CopyWebpackPlugin = require("copy-webpack-plugin");
77
const ExtractTextPlugin = require("extract-text-webpack-plugin");
8+
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
89
`;

Diff for: prepublish/common/plugins.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,13 @@ module.exports = `
2525
new nsWebpack.GenerateBundleStarterPlugin([
2626
"./vendor",
2727
"./bundle",
28-
]),`;
28+
]),
29+
30+
// Generate report files for bundles content
31+
new BundleAnalyzerPlugin({
32+
analyzerMode: "static",
33+
openAnalyzer: false,
34+
generateStatsFile: true,
35+
reportFilename: join(__dirname, "report", \`report.html\`),
36+
statsFilename: join(__dirname, "report", \`stats.json\`),
37+
}),`;

Diff for: templates/webpack.angular.js

+10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const nsWebpack = require("nativescript-dev-webpack");
55
const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target");
66
const CopyWebpackPlugin = require("copy-webpack-plugin");
77
const ExtractTextPlugin = require("extract-text-webpack-plugin");
8+
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
89

910
const { AotPlugin } = require("@ngtools/webpack");
1011

@@ -166,6 +167,15 @@ function getPlugins(platform, env) {
166167
"./bundle",
167168
]),
168169

170+
// Generate report files for bundles content
171+
new BundleAnalyzerPlugin({
172+
analyzerMode: "static",
173+
openAnalyzer: false,
174+
generateStatsFile: true,
175+
reportFilename: join(__dirname, "report", `report.html`),
176+
statsFilename: join(__dirname, "report", `stats.json`),
177+
}),
178+
169179
// Angular AOT compiler
170180
new AotPlugin({
171181
tsConfigPath: "tsconfig.aot.json",

Diff for: templates/webpack.javascript.js

+10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const nsWebpack = require("nativescript-dev-webpack");
55
const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target");
66
const CopyWebpackPlugin = require("copy-webpack-plugin");
77
const ExtractTextPlugin = require("extract-text-webpack-plugin");
8+
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
89

910

1011
const mainSheet = `app.css`;
@@ -154,6 +155,15 @@ function getPlugins(platform, env) {
154155
"./vendor",
155156
"./bundle",
156157
]),
158+
159+
// Generate report files for bundles content
160+
new BundleAnalyzerPlugin({
161+
analyzerMode: "static",
162+
openAnalyzer: false,
163+
generateStatsFile: true,
164+
reportFilename: join(__dirname, "report", `report.html`),
165+
statsFilename: join(__dirname, "report", `stats.json`),
166+
}),
157167
];
158168

159169
if (env.uglify) {

Diff for: templates/webpack.typescript.js

+10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const nsWebpack = require("nativescript-dev-webpack");
55
const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target");
66
const CopyWebpackPlugin = require("copy-webpack-plugin");
77
const ExtractTextPlugin = require("extract-text-webpack-plugin");
8+
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
89

910

1011
const mainSheet = `app.css`;
@@ -163,6 +164,15 @@ function getPlugins(platform, env) {
163164
"./vendor",
164165
"./bundle",
165166
]),
167+
168+
// Generate report files for bundles content
169+
new BundleAnalyzerPlugin({
170+
analyzerMode: "static",
171+
openAnalyzer: false,
172+
generateStatsFile: true,
173+
reportFilename: join(__dirname, "report", `report.html`),
174+
statsFilename: join(__dirname, "report", `stats.json`),
175+
}),
166176
];
167177

168178
if (env.uglify) {

0 commit comments

Comments
 (0)