const fs = require ( 'fs' ) ; const path = require ( 'path' ) ; const HtmlWebPackPlugin = require ( 'html-webpack-plugin' ) ; const ReactRefreshPlugin = require ( '@pmmmwh/react-refresh-webpack-plugin' ) ; const appDirectory = fs . realpathSync ( process . cwd ( ) ) ; const resolveApp = relativePath => path . resolve ( appDirectory , relativePath ) ; const configFactory = { createDefaultConfig , plugins : { reactRefresh ( options ) { return new ReactRefreshPlugin ( options ) ; } , indexHtml ( options ) { return new HtmlWebPackPlugin ( { filename : '../index.html' , title : '' , inject : true , template : path . join ( __dirname , '/../index.ejs' ) , ... options , } ) ; } , } , rules : { fonts ( ) { return { test : /fonts\/(.)+\.(woff|woff2|ttf|eot|svg)/ , loader : 'url-loader' , options : { limit : 102400 , name : '/assets/fonts/[name].[ext]' , } , } ; } , svg ( ) { return { test : /\.svg$/ , loader : 'svg-url-loader' , exclude : /node_modules/ , } ; } , css ( ) { return { test : /\.(css)$/ , use : [ 'style-loader' , 'css-loader' ] , } ; } , images ( ) { return { test : /\.(png|jpg|gif|ico)$/ , loader : 'url-loader' , options : { limit : 10000 , name : '/assets/img/img-[hash:6].[ext]' , } , } ; } , jsx ( ) { return { test : /\.(ts|tsx|js|jsx)$/ , exclude : /(node_modules)|(assets)/ , use : [ { loader : 'babel-loader' , } , ] , } ; } , } , } ; return { import ( 'webpack' ) . webpack . Configuration } function createDefaultConfig ( ) { return { optimization : { splitChunks : { cacheGroups : { defaultVendors : { chunks : 'initial' , name : 'vendor' , test : /([\\/]node_modules[\\/])/ , } , common : { chunks : 'async' , minChunks : 2 , test : /([\\/]node_modules[\\/])/ , } , } , } , } , entry : { app : [ './src/boot' ] , } , output : { publicPath : '/web/app/' , path : resolveApp ( 'dist/app' ) , filename : '[name].[hash].js' , chunkFilename : '[name].[chunkhash].js' , } , resolve : { alias : { teleport : path . join ( __dirname , '/../../teleport/src' ) , 'e-teleport' : path . join ( __dirname , '/../../webapps.e/teleport/src' ) , design : path . join ( __dirname , '/../../design/src' ) , shared : path . join ( __dirname , '/../../shared' ) , } , modules : [ 'node_modules' , 'src' ] , extensions : [ '.ts' , '.tsx' , '.js' , '.jsx' ] , } , } ; } module . exports = configFactory ;