-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.js
95 lines (93 loc) · 2.5 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
const exec = require('child_process').exec;
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const {LicenseWebpackPlugin} = require('license-webpack-plugin');
function versionName() {
return new Promise((resolve, reject) => {
exec('git describe --tags --always --dirty', (err, stdout, _stderr) =>
err ? reject(err) : resolve(`Build ${stdout.replace('\n', '')}`)
);
});
}
module.exports = {
mode: 'development',
entry: {
// Stop context menu feature on c44a127b
// eventpage: './src/eventpage.ts',
sandbox: './src/sandbox.ts',
popup: './src/popup.tsx',
options: './src/options.tsx',
},
output: {
path: `${__dirname}/build/`,
filename: '[name].js',
},
resolve: {
extensions: ['.js', '.ts', '.tsx', '.json'],
},
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.tsx?$/,
use: 'ts-loader',
},
],
},
plugins: [
new CleanWebpackPlugin({cleanStaleWebpackAssets: false}),
new CopyWebpackPlugin({
patterns: [
{
from: 'src/manifest.json',
transform: (content, _path) => {
return versionName().then(versionName => {
return JSON.stringify({
...JSON.parse(content.toString()),
version: process.env.npm_package_version,
version_name: versionName,
});
});
},
},
{
from: 'src/img/',
to: 'img/',
},
],
}),
new HtmlWebpackPlugin({
chunks: ['sandbox'],
template: 'src/sandbox.html',
filename: 'sandbox.html',
}),
new HtmlWebpackPlugin({
chunks: ['popup'],
template: 'src/popup.html',
filename: 'popup.html',
}),
new HtmlWebpackPlugin({
chunks: ['options'],
template: 'src/options.html',
filename: 'options.html',
}),
new LicenseWebpackPlugin({
perChunkOutput: false,
licenseTextOverrides: {
// LICENSE file is not included in the package
'styled-components':
'https://github.com/styled-components/styled-components/blob/master/LICENSE',
isarray: 'https://github.com/juliangruber/isarray/blob/master/LICENSE',
},
}),
],
performance: {
maxEntrypointSize: 2000000,
maxAssetSize: 2000000,
},
devtool: 'inline-source-map',
};