// shared config (dev and prod) const { resolve } = require('path'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const portFinderSync = require('portfinder-sync'); const dotenv = require('dotenv'); const webpack = require('webpack'); const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); dotenv.config(); console.log(resolve(__dirname, './src/')); const config = { mode: 'development', devtool: 'source-map', entry: resolve(__dirname, './src/index.tsx'), devServer: { historyApiFallback: true, open: true, hot: true, liveReload: true, port: 3000, static: { directory: resolve(__dirname, 'public'), publicPath: '/', watch: true, }, }, target: 'web', output: { path: resolve(__dirname, './build'), publicPath: '/', }, resolve: { extensions: ['.ts', '.tsx', '.js', '.jsx'], plugins: [new TsconfigPathsPlugin({})], }, module: { rules: [ { test: [/\.jsx?$/, /\.tsx?$/], use: ['babel-loader'], exclude: /node_modules/, }, { test: /\.css$/, use: ['css-loader'], }, { test: /\.(jpe?g|png|gif|svg)$/i, use: [ 'file-loader?hash=sha512&digest=hex&name=img/[chunkhash].[ext]', 'image-webpack-loader?bypassOnDebug&optipng.optimizationLevel=7&gifsicle.interlaced=false', ], }, { test: /\.(ttf|eot|woff|woff2)$/, use: ['file-loader'], }, ], }, plugins: [ new HtmlWebpackPlugin({ template: 'src/index.html.ejs' }), new webpack.ProvidePlugin({ process: 'process/browser', }), new webpack.DefinePlugin({ 'process.env': JSON.stringify(process.env), }), ], performance: { hints: false, }, }; module.exports = config;