-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.ts
103 lines (95 loc) · 2.58 KB
/
webpack.config.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
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
100
101
102
103
// tslint:disable no-implicit-dependencies
import * as CopyWebpackPlugin from 'copy-webpack-plugin';
import * as MiniCssExtractPlugin from 'mini-css-extract-plugin';
import * as path from 'path';
import * as webpack from 'webpack';
function transformManifest(content: string): string {
const manifest = JSON.parse(content);
const packageData = require('./package.json');
manifest.name = packageData.productName;
manifest.description = packageData.description;
manifest.version = packageData.version;
manifest.author = packageData.author;
manifest.homepage_url = packageData.repository;
if (process.env.BROWSER === 'chrome') {
manifest.permissions.push('activeTab', 'https://gloapi.gitkraken.com/*');
delete manifest.browser_specific_settings;
} else {
manifest.permissions.push('<all_urls>');
delete manifest.key;
}
return JSON.stringify(manifest, null, 2);
}
const config: webpack.Configuration = {
entry: {
background: path.resolve(__dirname, 'src/background.ts'),
content: path.resolve(__dirname, 'src/content.ts'),
},
output: {
filename: 'js/[name].js',
path: path.resolve(__dirname, 'build'),
},
module: {
rules: [
{
exclude: /(node_modules)/,
loader: 'ts-loader',
test: /\.tsx?$/,
},
{
exclude: /(node_modules)/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
{
loader: 'postcss-loader',
options: {
plugins: [require('postcss-preset-env')()],
},
},
{
loader: 'sass-loader',
options: {
implementation: require('sass'),
},
},
],
test: /\.s?css$/,
},
],
},
optimization: {
minimize: false,
},
performance: {
hints: false,
},
resolve: {
extensions: ['.ts', '.tsx', '.js'],
},
plugins: [
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, 'assets/manifest.json'),
to: path.resolve(__dirname, 'build'),
transform: transformManifest,
},
{
from: path.resolve(__dirname, 'icons'),
to: path.resolve(__dirname, 'build/icons'),
},
{
from: path.resolve(__dirname, 'node_modules/webextension-polyfill/dist/browser-polyfill.min.js'),
to: path.resolve(__dirname, 'build/js'),
},
{
from: path.resolve(__dirname, 'LICENSE'),
to: path.resolve(__dirname, 'build'),
},
]),
new MiniCssExtractPlugin({
filename: 'css/[name].css',
}),
],
};
export default config;