File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change 11const path = require ( 'path' ) ;
2+ const { readdirSync } = require ( 'fs' )
23
34const webpack = require ( 'webpack' ) ;
45const BundleAnalyzerPlugin = require ( 'webpack-bundle-analyzer' ) . BundleAnalyzerPlugin ;
56const HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ;
67
8+ const CURRENT_SCENARIO = 'basic' ;
9+
10+ const hasCurrentScenario = ( ) =>
11+ readdirSync ( __dirname , { withFileTypes : true } )
12+ . filter ( dir => dir . isDirectory ( ) )
13+ . find ( dir => dir . name === CURRENT_SCENARIO )
14+
15+ if ( ! hasCurrentScenario ( ) ) {
16+ throw new Error ( `Scenario "${ CURRENT_SCENARIO } " does not exist` )
17+ }
18+
19+ // eslint-disable-next-line no-console
20+ console . log ( `Bundling scenario: ${ CURRENT_SCENARIO } ` )
21+
722webpack (
823 {
9- mode : 'development ' ,
10- entry : path . resolve ( __dirname , 'perf-auto' ) ,
24+ mode : 'production ' ,
25+ entry : path . resolve ( __dirname , CURRENT_SCENARIO ) ,
1126 output : {
1227 filename : 'main.js' ,
13- path : path . resolve ( __dirname , 'dist' , 'perf-auto' ) ,
28+ path : path . resolve ( __dirname , 'dist' , CURRENT_SCENARIO ) ,
1429 } ,
1530 plugins : [ new BundleAnalyzerPlugin ( { analyzerMode : 'static' } ) , new HtmlWebpackPlugin ( ) ] ,
1631 } ,
You can’t perform that action at this time.
0 commit comments