generated from aeksco/react-typescript-web-extension-starter
-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathwebpack.common.js
52 lines (51 loc) · 1.36 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
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: {
'background-page': path.join(__dirname, 'src/background-page/background-page.ts'),
popup: path.join(__dirname, 'src/popup/popup.tsx'),
'content-script': './src/content-script/content-script.ts',
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js',
clean: true,
},
module: {
rules: [
{
exclude: /node_modules/,
test: /\.tsx?$/,
use: 'ts-loader',
},
{
test: /\.(png|jpe?g|gif|eot|ttf|woff|woff2)$/i,
// More information here https://webpack.js.org/guides/asset-modules/
type: 'asset',
},
{
test: /\.svg$/,
use: ['@svgr/webpack'],
},
],
},
plugins: [
new CopyWebpackPlugin({
patterns: [{ from: 'src/assets', to: './assets' }, { from: './src/manifest.json' }],
}),
new HtmlWebpackPlugin({
filename: 'popup.html',
template: 'src/popup/popup.html',
chunks: ['popup'],
}),
],
// Setup @src path resolution for TypeScript files
resolve: {
extensions: ['.ts', '.tsx', '.js', '.json'],
alias: {
'@src': path.resolve(__dirname, 'src/'),
'@test': path.resolve(__dirname, 'test/'),
},
},
};