webpack.config.js 785 Bytes
const path = require('path');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;

const plugins = [];
let devtool;

if (process.argv.some(a => a === '--report')) {
  plugins.push(new BundleAnalyzerPlugin());
}
if (process.argv.some(a => a === 'development')) {
  devtool = 'source-map';
}


module.exports = {
  entry: './src/index.ts',
  mode: 'production',
  devtool,
  output: {
    path: path.join(__dirname, '../dist'),
    filename: 'apm.js',
    libraryTarget: 'umd',
    library: 'apm'
  },
  resolve: {
    extensions: ['.ts', '.js'],
    modules: [
      'node_modules'
    ]
  },
  module: {
    rules: [
      {
        test: /\.(ts|js)x?$/,
        exclude: /node_modules/,
        loader: 'babel-loader'
      }
    ]
  },
  plugins
};