-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
114 lines (112 loc) · 3.11 KB
/
webpack.config.js
File metadata and controls
114 lines (112 loc) · 3.11 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
const path = require('path');
const CopyPlugin = require('copy-webpack-plugin');
const HtmlPlugin = require('html-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
module.exports = (env, argv) => {
const isProduction = argv.mode === 'production';
return {
entry: {
sidepanel: path.resolve('src/sidepanel/index.tsx'),
background: path.resolve('src/background.ts'),
content: path.resolve('src/content.ts')
},
module: {
rules: [
{
test: /\.tsx?$/,
use: {
loader: 'swc-loader',
options: {
jsc: {
parser: {
syntax: 'typescript',
tsx: true
},
target: 'es2020',
transform: {
react: {
runtime: 'classic',
pragma: 'React.createElement',
pragmaFrag: 'React.Fragment'
}
}
},
module: {
type: 'es6'
}
}
},
exclude: /node_modules/
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader', 'postcss-loader']
}
]
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
// Add caching for module resolution
cache: true
},
plugins: [
new CopyPlugin({
patterns: [
{ from: 'manifest.json', to: 'manifest.json' },
{ from: 'icon*.png', to: '[name][ext]' },
{ from: 'logo.png', to: 'logo.png' },
{ from: 'jumango.gif', to: 'jumango.gif' },
{ from: 'src/inject.js', to: 'inject.js' },
{ from: 'src/worklets/spectral-gate-processor.js', to: 'src/worklets/spectral-gate-processor.js' },
{ from: 'src/worklets/spectral-compressor-processor.js', to: 'src/worklets/spectral-compressor-processor.js' },
{ from: 'src/worklets/spectral-pitch-processor.js', to: 'src/worklets/spectral-pitch-processor.js' }
]
}),
new HtmlPlugin({
template: 'src/sidepanel/index.html',
filename: 'sidepanel.html',
chunks: ['sidepanel']
})
],
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist'),
clean: true
},
optimization: {
minimize: isProduction,
minimizer: [
new TerserPlugin({
terserOptions: {
compress: {
drop_console: isProduction,
drop_debugger: isProduction
},
format: {
comments: false
}
},
extractComments: false,
parallel: true
})
],
splitChunks: {
chunks: 'all'
}
},
// Disable source maps in production for faster builds
devtool: isProduction ? false : 'eval-source-map',
// Enable caching
cache: {
type: 'filesystem',
allowCollectingMemory: true,
buildDependencies: {
config: [__filename]
}
},
// Performance hints
performance: {
hints: false
}
};
};