65 lines
1.5 KiB
JavaScript
Raw Normal View History

2021-02-17 00:11:08 -08:00
/* eslint-disable no-undef */
const path = require('path');
2022-01-26 19:25:11 +00:00
const webpack = require('webpack');
2021-02-16 12:01:32 -08:00
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
2020-12-08 19:35:02 -08:00
2022-01-26 19:25:11 +00:00
webpack;
2021-02-16 12:01:32 -08:00
module.exports = {
2020-12-06 16:31:48 -08:00
entry: {
2022-01-26 19:25:11 +00:00
app: path.join(__dirname, 'src', 'index.tsx'),
2020-12-06 16:31:48 -08:00
},
target: 'web',
resolve: {
2022-01-26 19:25:11 +00:00
extensions: ['.ts', '.tsx', '.js', '.jsx'],
2020-12-06 16:31:48 -08:00
},
2021-02-16 11:11:13 -08:00
output: {
filename: '[name].bundle.js',
2022-01-26 19:25:11 +00:00
path: path.resolve(__dirname, 'dist'),
2021-02-16 11:11:13 -08:00
},
2020-12-06 16:31:48 -08:00
module: {
2022-01-26 19:25:11 +00:00
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: '/node_modules/',
},
{
test: /\.(png|jpe?g|gif|svg)$/,
type: 'asset/inline',
},
],
2020-12-06 16:31:48 -08:00
},
2021-02-16 11:11:13 -08:00
optimization: {
usedExports: true,
splitChunks: {
cacheGroups: {
vendors: {
2021-02-25 23:01:12 -08:00
test: /node_modules\/.*/,
2022-01-26 19:25:11 +00:00
name: 'vendors',
chunks: 'all',
},
2021-02-16 11:11:13 -08:00
},
2022-01-26 19:25:11 +00:00
},
2021-02-16 11:11:13 -08:00
},
2020-12-06 16:31:48 -08:00
plugins: [
2022-02-05 13:53:10 -08:00
new CleanWebpackPlugin({
dangerouslyAllowCleanPatternsOutsideProject: true,
dry: false,
}),
new CopyWebpackPlugin({
2022-01-26 19:25:11 +00:00
patterns: [
{
from: 'public/*',
to: '[name].[ext]',
globOptions: {
ignore: ['**/index.html'],
},
},
],
}),
],
};