-
Notifications
You must be signed in to change notification settings - Fork 13
/
webpack.config.js
63 lines (62 loc) · 1.92 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
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const WebpackHookPlugin = require('webpack-hook-plugin');
module.exports = {
entry: {
popup: './src/popup.tsx',
content: './src/content.tsx',
background: './src/background.ts',
},
module: {
rules: [
{ test: /\.([cm]?ts|tsx)$/, loader: "ts-loader" },
{
test: /\.s[ac]ss$/i,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader',
],
},
{
test: /\.(png|svg|jpg|gif)$/,
use: [
'file-loader',
],
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
use: [
'file-loader',
],
},
],
},
plugins: [
new MiniCssExtractPlugin({
filename: 'firefox/static/css/[name].css',
}),
new CopyPlugin({
patterns: [
{ from: path.resolve(__dirname, 'public/popup.html'), to: path.resolve(__dirname, 'build/firefox') },
{ from: path.resolve(__dirname, 'public/images'), to: path.resolve(__dirname, 'build/firefox/images') },
{ from: path.resolve(__dirname, 'public/popup.html'), to: path.resolve(__dirname, 'build/chrome') },
{ from: path.resolve(__dirname, 'public/images'), to: path.resolve(__dirname, 'build/chrome/images') },
{ from: path.resolve(__dirname, 'public/manifests/firefox.json'), to: path.resolve(__dirname, 'build/firefox/manifest.json') },
{ from: path.resolve(__dirname, 'public/manifests/chrome.json'), to: path.resolve(__dirname, 'build/chrome/manifest.json') },
],
}),
new WebpackHookPlugin({
onBuildEnd: ['node src/utils/build.js']
})
],
resolve: {
extensions: ['.tsx', 'jsx', '.ts', '.js'],
},
output: {
filename: 'firefox/static/js/[name].js',
path: path.resolve(__dirname, 'build'),
},
mode: 'production',
};