-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
webpack.config.ts
65 lines (64 loc) · 1.45 KB
/
webpack.config.ts
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
// tslint:disable: no-implicit-dependencies
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
import CopyWebpackPlugin from 'copy-webpack-plugin';
import { resolve } from 'path';
import webpack, { WebpackPluginInstance } from 'webpack';
module.exports = (_env: string, argv: Record<string, boolean | number | string>): webpack.Configuration => ({
output: {
path: resolve(__dirname, 'dist'),
},
devtool: argv.mode === 'production' ? undefined : 'source-map',
entry: {
background: './src/js/background.ts',
options: './src/js/options.ts',
},
// tslint:disable-next-line: object-literal-sort-keys
module: {
rules: [
{
exclude: /node_modules/,
test: /\.ts$/,
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true,
compilerOptions: {
module: 'esnext',
noEmitOnError: argv.watch === false,
},
},
},
],
},
],
},
plugins: [
(new CleanWebpackPlugin() as unknown) as WebpackPluginInstance,
(new CopyWebpackPlugin({
patterns: [
{
context: 'src',
from: '*',
globOptions: {
ignore: ['*.js', '*.ts'],
},
},
{
context: 'src/images',
from: '*',
globOptions: {
ignore: ['*.js', '*.ts'],
},
to: 'images',
},
{
from: 'node_modules/webextension-polyfill/dist/browser-polyfill.min.js',
},
],
}) as unknown) as WebpackPluginInstance,
],
resolve: {
extensions: ['.ts'],
},
});