-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
99 lines (94 loc) · 2.15 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/* eslint-disable */
const path = require('path');
const ROOT = path.resolve(__dirname);
const CopyPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const YamlLocalesWebpackPlugin = require('yaml-locales-webpack-plugin');
const mode = process.env.MODE;
const entry = {
background: [ROOT + '/src/background'],
content_script: [ROOT + '/src/content_script/index'],
'options/index': [ROOT + '/src/options/index'],
'popup/index': [ROOT + '/src/popup/index'],
};
const config = {
entry: entry,
mode: mode,
experiments: { topLevelAwait: true },
output: {
path: ROOT + '/chrome',
filename: '[name].bundle.js',
sourceMapFilename: '[name].bundle.map.js',
},
module: {
rules: [
{
test: /\.js[x]?$/,
exclude: /node_modules/,
use: ['babel-loader'],
},
{
test: /\.ts[x]?$/,
loader: 'ts-loader',
},
{
test: /\.css$/,
include: ROOT + '/src',
use: [
{
loader: 'style-loader',
},
{
loader: 'css-loader',
},
],
},
],
},
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
alias: {
'@': ROOT + '/src',
},
},
plugins: [
new CopyPlugin([
{
from: 'src/manifest.json',
to: './',
},
{
from: 'src/assets',
to: './assets',
},
]),
new HtmlWebpackPlugin({
filename: 'popup/index.html',
template: 'src/popup/index.html',
inject: true,
chunks: ['popup/index'],
minify: {
removeComments: true,
collapseWhitespace: true,
},
}),
new HtmlWebpackPlugin({
filename: 'options/index.html',
template: 'src/options/index.html',
inject: true,
chunks: ['options/index'],
minify: {
removeComments: true,
collapseWhitespace: true,
},
}),
new YamlLocalesWebpackPlugin({
yamlFile: 'src/i18n/messages.yaml',
defaultLanguage: 'en',
}),
],
};
if (mode === 'development') {
config.devtool = 'cheap-module-source-map'
}
module.exports = config;