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 1
1
const path = require ( 'path' ) ;
2
+ const { readdirSync } = require ( 'fs' )
2
3
3
4
const webpack = require ( 'webpack' ) ;
4
5
const BundleAnalyzerPlugin = require ( 'webpack-bundle-analyzer' ) . BundleAnalyzerPlugin ;
5
6
const HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ;
6
7
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
+
7
22
webpack (
8
23
{
9
- mode : 'development ' ,
10
- entry : path . resolve ( __dirname , 'perf-auto' ) ,
24
+ mode : 'production ' ,
25
+ entry : path . resolve ( __dirname , CURRENT_SCENARIO ) ,
11
26
output : {
12
27
filename : 'main.js' ,
13
- path : path . resolve ( __dirname , 'dist' , 'perf-auto' ) ,
28
+ path : path . resolve ( __dirname , 'dist' , CURRENT_SCENARIO ) ,
14
29
} ,
15
30
plugins : [ new BundleAnalyzerPlugin ( { analyzerMode : 'static' } ) , new HtmlWebpackPlugin ( ) ] ,
16
31
} ,
You can’t perform that action at this time.
0 commit comments