const path = require ( 'path' ) ; const CopyPlugin = require ( 'copy-webpack-plugin' ) ; const HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ; const webpack = require ( 'webpack' ) ; const OUTPUT_BASE = path . resolve ( __dirname , '../../build/server_manager/web_app/static' ) ; const GENERATE_CSS_RTL_LOADER = path . resolve ( __dirname , 'css-in-js-rtl-loader.js' ) ; const CIRCLE_FLAGS_PATH = path . dirname ( require . resolve ( 'circle-flags/package.json' ) ) ; exports . makeConfig = ( options ) => { return { mode : options . defaultMode , entry : [ require . resolve ( '@webcomponents/webcomponentsjs/webcomponents-loader.js' ) , path . resolve ( __dirname , './web_app/ui_components/style.css' ) , options . main , ] , target : options . target , devtool : 'inline-source-map' , devServer : { overlay : true , } , output : { path : OUTPUT_BASE , filename : 'main.js' } , module : { rules : [ { test : /\.ts(x)?$/ , exclude : /node_modules/ , use : [ 'ts-loader' , GENERATE_CSS_RTL_LOADER , ] , } , { test : /\.js$/ , exclude : /node_modules/ , loader : GENERATE_CSS_RTL_LOADER , } , { test : /\.css?$/ , use : [ 'style-loader' , 'css-loader' , ] , } ] } , resolve : { extensions : [ '.tsx' , '.ts' , '.js' ] } , plugins : [ new webpack . DefinePlugin ( { 'outline.gcpAuthEnabled' : JSON . stringify ( process . env . GCP_AUTH_ENABLED === 'true' ) , 'process.type' : JSON . stringify ( 'renderer' ) , 'window.polymerSkipLoadingFontRoboto' : JSON . stringify ( true ) , } ) , new webpack . IgnorePlugin ( /^electron$/ ) , new CopyPlugin ( [ { from : 'index.html' , to : '.' } , { from : `${ CIRCLE_FLAGS_PATH }/flags` , to : 'images/flags' } , { from : 'images' , to : 'images' } , { from : 'messages' , to : 'messages' } , ] , { context : __dirname } ) , new HtmlWebpackPlugin ( { template : options . template || path . resolve ( __dirname , './index.html' ) , } ) , ] , } ; } ;