Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/wojtekmaj/react-async-button. A button that handles Promises for your React app.
Something went wrong. Try again.
2.0 kB · 76 lines
JavaScript
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');const MiniCssExtractPlugin = require('mini-css-extract-plugin');const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const isProduction = process.env.NODE_ENV === 'production';const isDevelopment = !isProduction;
module.exports = { mode: isProduction ? 'production' : 'development', bail: isProduction, context: path.join(__dirname), entry: { src: './index.jsx', }, output: { path: path.resolve(__dirname, 'dist'), publicPath: '/', filename: '[name].[chunkhash:8].js', }, resolve: { alias: { react: require.resolve('react'), 'react-dom/client': require.resolve('react-dom/client'), 'react-dom': require.resolve('react-dom'), }, extensions: ['.js', '.jsx'], symlinks: false, }, module: { rules: [ { test: /\.jsx?$/, exclude: /node_modules(?!\/@wojtekmaj\/react-async-button)/, use: [ { loader: 'babel-loader', options: { babelrcRoots: ['.', '../'], plugins: [isDevelopment && 'react-refresh/babel'].filter(Boolean), }, }, ], }, { test: /\.css$/, use: [isProduction ? MiniCssExtractPlugin.loader : 'style-loader', 'css-loader'], }, ].filter(Boolean), }, plugins: [ new HtmlWebpackPlugin({ template: 'index.html', }), isProduction && new MiniCssExtractPlugin({ filename: '[name].[chunkhash:8].css', chunkFilename: '[name].[chunkhash:8].css', }), isDevelopment && new ReactRefreshWebpackPlugin(), ].filter(Boolean), optimization: { moduleIds: 'named', }, stats: { assetsSort: '!size', entrypoints: false, }, devServer: { compress: true, historyApiFallback: true, // respond to 404s with index.html hot: true, // enable HMR on the server port: 3000, },};