Skip to content

Commit

Permalink
Merge pull request #47 from hepsiburada/feature/webpack-bundle-analyze
Browse files Browse the repository at this point in the history
webpack budnle analyze static file added
  • Loading branch information
burakilk authored Jun 29, 2022
2 parents fc8a8b0 + 398023b commit 4b62388
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import { HTTP_STATUS_CODES } from './universal/utils/constants';

import voltranConfig from '../voltran.config';

const {bundleAnalyzerStaticEnabled} = require('__APP_CONFIG__');

const enablePrometheus = voltranConfig.monitoring.prometheus;
let Prometheus;

Expand Down Expand Up @@ -163,6 +165,11 @@ if (process.env.NODE_ENV === 'production') {
hiddie.use(helmet());
hiddie.use(cors);
hiddie.use('/', serveStatic(`${voltranConfig.distFolder}/public`));
bundleAnalyzerStaticEnabled &&
hiddie.use(
'/bundleAnalyze',
serveStatic(`${voltranConfig.distFolder}/public/project/assets/report.html`)
);
hiddie.use(cookieParser());
hiddie.use(utils);
hiddie.use(handleUrls);
Expand Down
3 changes: 1 addition & 2 deletions webpack.client.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const {createComponentName} = require('./src/universal/utils/helper.js');
const packageJson = require(path.resolve(process.cwd(), 'package.json'));

const isBuildingForCDN = process.argv.includes('--for-cdn');
const isAnalyze = process.argv.includes('--analyze');
const env = process.env.VOLTRAN_ENV || 'local';

const voltranConfig = require('./voltran.config');
Expand Down Expand Up @@ -266,7 +265,7 @@ const clientConfig = merge(commonConfig, voltranClientConfig, {
prettyPrint: true,
}),

...(isAnalyze ? [new BundleAnalyzerPlugin()] : [])
new BundleAnalyzerPlugin({analyzerMode: 'static'}),
]
});

Expand Down

0 comments on commit 4b62388

Please sign in to comment.