-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathwebpack.common.js
70 lines (69 loc) · 2.06 KB
/
webpack.common.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const path = require('path')
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
module.exports = {
mode: 'development',
module: {
rules: [
{
test: /\.(jpg|svg|png|webp|lottie|ogg|m4a|mp3|ac3|webm)$/,
type: 'asset/resource',
},
{
test: /\.(tsx|jsx)$/,
exclude: /node_modules/,
loader: 'esbuild-loader',
options: {
loader: 'tsx',
target: 'esnext',
jsx: 'automatic',
},
},
{
test: /\.(ts|js)$/,
exclude: /node_modules/,
loader: 'esbuild-loader',
options: {
loader: 'ts',
target: 'esnext',
},
},
],
},
plugins: [
new LodashModuleReplacementPlugin(),
new CopyWebpackPlugin({
patterns: [
{
from: './node_modules/pdfjs-dist/cmaps',
to: './static/cmaps',
},
{
from: './node_modules/pdfjs-dist/web/images/annotation-*',
to: './static/media/annotation/[name].[ext]',
},
{
from: './node_modules/pdfjs-dist/build/pdf.worker.js',
to: './pdf.worker.js',
},
{
from: './nginx-routes.conf',
to: './nginx-routes.conf',
},
],
}),
],
resolve: {
extensions: ['*', '.mjs', '.js', '.jsx', '.ts', '.tsx'],
fallback: {
events: require.resolve('events'),
},
},
output: {
clean: true,
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
filename: '[name].js',
assetModuleFilename: 'assets/[name].[hash][ext][query]',
},
}