-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
74 lines (70 loc) · 1.52 KB
/
webpack.config.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
71
72
73
74
const CopyPlugin = require('copy-webpack-plugin');
const backgroundAndCssConfig = {
entry: [
'./src/features/team-page/background.ts',
'./src/features/match-page/background.ts',
],
mode: 'none',
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'babel-loader',
},
{
test: /\.js$/,
use: ['source-map-loader'],
enforce: 'pre',
},
],
},
output: {
filename: 'background.js',
},
resolve: {
extensions: ['.ts', '.js'],
},
plugins: [
new CopyPlugin({
patterns: [
{ from: 'src/features/team-page/styles.css', to: 'content/team-page/styles.css' },
{ from: 'src/features/match-page/styles.css', to: 'content/match-page/styles.css' },
],
}),
],
};
const contentScripts = [
'content.ts',
'team-page/content.ts',
'match-page/content.ts',
];
const contentScriptConfigs = contentScripts.map(contentScriptPath => {
const jsFilePath = contentScriptPath.replace('.ts', '.js');
return {
entry: './src/features/' + contentScriptPath,
mode: 'none',
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'babel-loader',
},
{
test: /\.js$/,
use: ['source-map-loader'],
enforce: 'pre',
},
],
},
output: {
filename: 'content/' + jsFilePath.replace('content', 'index'),
},
resolve: {
extensions: ['.ts', '.js'],
},
};
});
module.exports = [
backgroundAndCssConfig,
...contentScriptConfigs,
];