-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.common.ts
58 lines (55 loc) · 1.55 KB
/
webpack.common.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
import path from 'path';
import webpack from 'webpack';
import {TsconfigPathsPlugin} from 'tsconfig-paths-webpack-plugin'
import CopyWebpackPlugin from 'copy-webpack-plugin'
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'
import HtmlWebpackPlugin = require('html-webpack-plugin')
const src = path.join(__dirname, 'src')
const build = path.join(__dirname, 'build')
const config: webpack.Configuration = {
entry: {
contentscript: path.join(__dirname, 'src/contentscript/contentscript.ts'),
background: path.join(__dirname, 'src/background/background.ts'),
popup: path.join(__dirname, 'src/popup/index.tsx')
},
output: {
path: build,
filename: '[name].js',
},
module: {
rules: [
{
test: /\.tsx$/,
use: ['babel-loader', 'eslint-loader'],
exclude: /node_modules/
},
]
},
resolve: {
plugins: [new TsconfigPathsPlugin()],
extensions: ['.ts', '.tsx', '.js', '.json'],
},
plugins: [
new ForkTsCheckerWebpackPlugin(),
new HtmlWebpackPlugin({
template: path.join(__dirname, 'popup.html'),
inject: 'body',
filename: 'popup.html',
title: 'React TS Starter',
chunks: ['popup'],
}),
new CopyWebpackPlugin([
{
from: path.join(src, 'assets'),
to: path.join(build, 'assets'),
test: /\.(jpg|jpeg|png|gif|svg)?$/,
},
{
from: path.join(path.resolve(src, '..'), 'manifest.json'),
to: path.join(build, 'manifest.json'),
toType: 'file',
}
])
]
};
export default config;