79 lines
1.7 KiB
JavaScript
79 lines
1.7 KiB
JavaScript
const path = require('path');
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
module.exports = {
|
|
entry: './src/index.tsx',
|
|
output: {
|
|
filename: 'bundle.[contenthash].js',
|
|
path: path.resolve(__dirname, 'dist'),
|
|
clean: true,
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.[jt]sx?$/,
|
|
exclude: /node_modules/,
|
|
use: {
|
|
loader: 'babel-loader',
|
|
},
|
|
},
|
|
{
|
|
test: /\.css$/i,
|
|
use: ['style-loader', 'css-loader'],
|
|
},
|
|
{
|
|
test: /\.svg$/i,
|
|
issuer: /\.[jt]sx?$/,
|
|
use: ['@svgr/webpack'],
|
|
},
|
|
{
|
|
test: /\.svg$/i,
|
|
type: 'asset/resource',
|
|
issuer: { not: [/\.[jt]sx?$/] },
|
|
},
|
|
],
|
|
},
|
|
plugins: [
|
|
new HtmlWebpackPlugin({
|
|
template: path.resolve(__dirname, 'src/index.html'),
|
|
favicon: false,
|
|
}),
|
|
new CopyWebpackPlugin({
|
|
patterns: [
|
|
{
|
|
from: path.resolve(__dirname, 'node_modules/pdfjs-dist/wasm'),
|
|
to: 'pdfjs/wasm',
|
|
},
|
|
],
|
|
}),
|
|
],
|
|
devServer: {
|
|
static: [
|
|
{
|
|
directory: path.join(__dirname, 'public'),
|
|
},
|
|
{
|
|
directory: path.resolve(__dirname, 'node_modules/pdfjs-dist/wasm'),
|
|
publicPath: '/pdfjs/wasm',
|
|
watch: false,
|
|
},
|
|
],
|
|
compress: true,
|
|
port: 5173,
|
|
historyApiFallback: true,
|
|
open: true,
|
|
proxy: [
|
|
{
|
|
context: ['/api', '/download'],
|
|
target: 'http://127.0.0.1:3000',
|
|
changeOrigin: true,
|
|
secure: false,
|
|
},
|
|
],
|
|
},
|
|
devtool: 'source-map',
|
|
resolve: {
|
|
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
|
},
|
|
};
|