github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/scripts/webpack/webpack.flamegraph.ts (about) 1 import path from 'path'; 2 import MiniCssExtractPlugin from 'mini-css-extract-plugin'; 3 import { ESBuildMinifyPlugin } from 'esbuild-loader'; 4 import webpack from 'webpack'; 5 import { getAlias, getJsLoader, getStyleLoaders } from './shared'; 6 7 const common = { 8 mode: 'production', 9 devtool: 'source-map', 10 11 resolve: { 12 extensions: ['.ts', '.tsx', '.es6', '.js', '.jsx', '.json', '.svg'], 13 alias: getAlias(), 14 modules: [ 15 'node_modules', 16 path.resolve('webapp'), 17 path.resolve('node_modules'), 18 ], 19 }, 20 21 watchOptions: { 22 ignored: /node_modules/, 23 }, 24 25 optimization: { 26 minimizer: [ 27 new ESBuildMinifyPlugin({ 28 target: 'es2015', 29 css: true, 30 }), 31 ], 32 }, 33 34 module: { 35 // Note: order is bottom-to-top and/or right-to-left 36 rules: [ 37 ...getJsLoader(), 38 ...getStyleLoaders(), 39 { 40 test: /\.svg$/, 41 use: [ 42 { loader: 'babel-loader' }, 43 { 44 loader: 'react-svg-loader', 45 options: { 46 svgo: { 47 plugins: [ 48 { convertPathData: { noSpaceAfterFlags: false } }, 49 { removeViewBox: false }, 50 ], 51 }, 52 }, 53 }, 54 ], 55 }, 56 ], 57 }, 58 59 plugins: [ 60 new MiniCssExtractPlugin({}), 61 new webpack.DefinePlugin({ 62 'process.env': { 63 PYROSCOPE_HIDE_LOGO: process.env['PYROSCOPE_HIDE_LOGO'], 64 }, 65 }), 66 ], 67 }; 68 69 export default [ 70 { 71 ...common, 72 target: 'node', 73 mode: 'production', 74 // devtool: 'source-map', 75 entry: { 76 index: './src/index.node.ts', 77 }, 78 output: { 79 publicPath: '', 80 path: path.resolve(__dirname, '../../packages/pyroscope-flamegraph/dist'), 81 libraryTarget: 'commonjs', 82 filename: 'index.node.js', 83 }, 84 85 externals: { 86 react: 'react', 87 'react-dom': 'react-dom', 88 }, 89 }, 90 { 91 ...common, 92 target: 'web', 93 mode: 'production', 94 // devtool: 'source-map', 95 entry: { 96 index: './src/index.tsx', 97 }, 98 output: { 99 publicPath: '', 100 path: path.resolve(__dirname, '../../packages/pyroscope-flamegraph/dist'), 101 libraryTarget: 'umd', 102 library: 'pyroscope', 103 filename: 'index.js', 104 globalObject: 'this', 105 }, 106 107 externals: { 108 react: 'react', 109 'react-dom': 'react-dom', 110 }, 111 }, 112 ];