Skip to content

Commit

Permalink
Run webpack-bundle-analyzer when using profile:bundle script (#468)
Browse files Browse the repository at this point in the history
  • Loading branch information
chacha912 authored Feb 27, 2023
1 parent 5f71ea6 commit be0f260
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 52 deletions.
107 changes: 56 additions & 51 deletions config/webpack.dev.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,62 +19,67 @@ const webpack = require('webpack');
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
const WebpackBundleAnalyzer = require('webpack-bundle-analyzer');

module.exports = {
entry: './src/yorkie',
devtool: 'inline-source-map',
mode: 'development',
module: {
rules: [
{
test: /\.ts$/,
use: {
loader: 'ts-loader',
options: {
configFile: path.resolve(__dirname, '../tsconfig.json'),
module.exports = (env, arg) => {
const config = {
entry: './src/yorkie',
devtool: 'inline-source-map',
mode: 'development',
module: {
rules: [
{
test: /\.ts$/,
use: {
loader: 'ts-loader',
options: {
configFile: path.resolve(__dirname, '../tsconfig.json'),
},
},
exclude: /node_modules/,
},
exclude: /node_modules/,
},
{
test: /\.ts$/,
exclude: [path.resolve(__dirname, 'test')],
enforce: 'post',
use: {
loader: 'istanbul-instrumenter-loader',
options: { esModules: true },
{
test: /\.ts$/,
exclude: [path.resolve(__dirname, 'test')],
enforce: 'post',
use: {
loader: 'istanbul-instrumenter-loader',
options: { esModules: true },
},
},
],
},
resolve: {
alias: {
'@yorkie-js-sdk/src': path.resolve(__dirname, '../src/'),
'@yorkie-js-sdk/test': path.resolve(__dirname, '../test/'),
},
],
},
resolve: {
alias: {
'@yorkie-js-sdk/src': path.resolve(__dirname, '../src/'),
'@yorkie-js-sdk/test': path.resolve(__dirname, '../test/'),
extensions: ['.ts', '.js'],
},
output: {
library: 'yorkie',
libraryTarget: 'umd',
libraryExport: 'default',
filename: 'yorkie.js',
path: path.resolve(__dirname, '../public/dist'),
},
extensions: ['.ts', '.js'],
},
output: {
library: 'yorkie',
libraryTarget: 'umd',
libraryExport: 'default',
filename: 'yorkie.js',
path: path.resolve(__dirname, '../public/dist'),
},
devServer: {
static: path.join(__dirname, '../public'),
compress: true,
hot: true,
host: '0.0.0.0',
port: 9000,
proxy: {
'/api': {
target: 'http://localhost:8080',
pathRewrite: { '^/api': '' },
devServer: {
static: path.join(__dirname, '../public'),
compress: true,
hot: true,
host: '0.0.0.0',
port: 9000,
proxy: {
'/api': {
target: 'http://localhost:8080',
pathRewrite: { '^/api': '' },
},
},
},
},
plugins: [
new WebpackBundleAnalyzer.BundleAnalyzerPlugin(),
new NodePolyfillPlugin(),
],
plugins: [new NodePolyfillPlugin()],
};

if (arg.profile) {
config.plugins.push(new WebpackBundleAnalyzer.BundleAnalyzerPlugin());
}

return config;
};
2 changes: 1 addition & 1 deletion config/webpack.karma.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

const config = require('./webpack.dev.config');
const config = require('./webpack.dev.config')({}, {});

// Do not include entry - karma-webpack does not support it
delete config.entry;
Expand Down

0 comments on commit be0f260

Please sign in to comment.