2022-04-13 10:48:10 -06:00
|
|
|
const path = require('path');
|
2022-04-17 21:59:56 -06:00
|
|
|
const dotenv = require('dotenv').config();
|
2022-04-15 09:28:11 -06:00
|
|
|
const webpack = require('webpack');
|
2022-04-13 10:48:10 -06:00
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
2022-04-15 23:51:26 -06:00
|
|
|
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
|
2022-04-19 18:21:16 -06:00
|
|
|
const ESLintPlugin = require('eslint-webpack-plugin');
|
2022-04-26 20:12:45 -06:00
|
|
|
const CopyPlugin = require('copy-webpack-plugin');
|
2022-04-24 23:44:06 -06:00
|
|
|
const PUBLIC_URL = process.env.PUBLIC_URL || '/';
|
2022-04-13 10:48:10 -06:00
|
|
|
|
|
|
|
module.exports = {
|
2022-04-25 09:12:43 -06:00
|
|
|
entry: ['webpack-hot-middleware/client?path=/reload_wss&timeout=2000&reload=true&autoConnect=true', './src/frontend/index.tsx'],
|
2022-04-19 18:21:16 -06:00
|
|
|
output: {
|
|
|
|
path: path.resolve(__dirname, 'build'),
|
|
|
|
filename: 'assets/app.js',
|
2022-04-24 23:44:06 -06:00
|
|
|
publicPath: PUBLIC_URL,
|
2022-04-19 18:21:16 -06:00
|
|
|
},
|
|
|
|
resolve: {
|
2022-04-22 09:00:14 -06:00
|
|
|
extensions: ['.js', '.jsx','.ts','.tsx', '.json'],
|
2022-04-19 18:21:16 -06:00
|
|
|
alias: {
|
2022-04-25 09:12:43 -06:00
|
|
|
'@components': path.resolve(__dirname, 'src/frontend/components/'),
|
|
|
|
'@styles': path.resolve(__dirname, 'src/frontend/styles/'),
|
2022-04-19 18:21:16 -06:00
|
|
|
}
|
|
|
|
},
|
2022-04-22 09:00:14 -06:00
|
|
|
devtool: 'inline-source-map',
|
2022-04-19 18:21:16 -06:00
|
|
|
mode: 'development',
|
2022-04-22 09:00:14 -06:00
|
|
|
context: __dirname,
|
2022-04-19 18:21:16 -06:00
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
2022-04-22 09:00:14 -06:00
|
|
|
test: /\.(js|jsx|ts|tsx)$/,
|
2022-04-19 18:21:16 -06:00
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: { plugins: ['react-refresh/babel'] }
|
|
|
|
},
|
2022-04-22 09:00:14 -06:00
|
|
|
exclude: /node_modules/,
|
2022-04-19 18:21:16 -06:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(css|sass|scss)$/,
|
|
|
|
use: [
|
|
|
|
MiniCssExtractPlugin.loader,
|
|
|
|
'css-loader',
|
|
|
|
'sass-loader',
|
|
|
|
],
|
|
|
|
},
|
2022-04-26 20:12:45 -06:00
|
|
|
{
|
|
|
|
test: /\.(png|jpg|jpeg|gif|svg|ico|mp4|avi|ttf|otf|eot|woff|woff2|pdf)$/,
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
|
|
|
name: 'assets/media/[name].[ext]',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(ttf|otf|eot|woff|woff2)$/,
|
|
|
|
loader: 'url-loader',
|
|
|
|
options: {
|
|
|
|
name: 'assets/fonts/[name].[ext]',
|
|
|
|
esModule: false,
|
|
|
|
},
|
|
|
|
},
|
2022-04-19 18:21:16 -06:00
|
|
|
]
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new webpack.HotModuleReplacementPlugin(),
|
|
|
|
new ReactRefreshWebpackPlugin(),
|
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: 'assets/app.css',
|
|
|
|
}),
|
|
|
|
new ESLintPlugin(),
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env': JSON.stringify(dotenv.parsed),
|
2022-04-24 23:44:06 -06:00
|
|
|
'process.env.PUBLIC_URL': JSON.stringify(PUBLIC_URL),
|
2022-04-19 18:21:16 -06:00
|
|
|
}),
|
2022-04-26 20:12:45 -06:00
|
|
|
new CopyPlugin({
|
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
from: './public/manifest.json', to: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
from: './public/favicon.ico', to: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
from: './public/logo192.png', to: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
from: './public/logo512.png', to: '',
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}),
|
2022-04-19 18:21:16 -06:00
|
|
|
],
|
|
|
|
optimization: {
|
|
|
|
splitChunks: {
|
|
|
|
chunks: 'async',
|
|
|
|
cacheGroups: {
|
|
|
|
vendors: {
|
|
|
|
name: 'vendors',
|
|
|
|
chunks: 'all',
|
|
|
|
reuseExistingChunk: true,
|
|
|
|
priority: 1,
|
|
|
|
filename: 'assets/vendor.js',
|
|
|
|
enforce: true,
|
|
|
|
test (module, chunks){
|
|
|
|
const name = module.nameForCondition && module.nameForCondition();
|
|
|
|
return chunks.name !== 'vendors' && /[\\/]node_modules[\\/]/.test(name);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|