-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
75 lines (71 loc) · 1.86 KB
/
webpack.config.js
File metadata and controls
75 lines (71 loc) · 1.86 KB
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
/* eslint-env node */
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const targetBrowser = process.env.TARGET_BROWSER;
const nodeEnv = process.env.NODE_ENV || 'development';
const srcPath = path.join(__dirname, 'src');
const destPath = path.join(__dirname, 'extension');
const viewsPath = path.join(__dirname, 'views');
module.exports = {
mode: nodeEnv,
entry: {
background: path.join(srcPath, 'background', 'index.ts'),
options: path.join(srcPath, 'option', 'index.tsx'),
},
output: {
path: path.join(destPath, targetBrowser),
filename: 'js/[name].bundle.js',
},
module: {
rules: [
{
test: /\.(js|ts)x?$/,
use: [{
loader: 'babel-loader',
}, {
loader: 'ts-loader',
options: {
transpileOnly: true,
},
}],
exclude: ['/node_modules/'],
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
],
},
resolve: {
extensions: ['.ts', '.tsx', '.js', 'json'],
alias: {
'webextension-polyfill-ts': path.resolve(
path.join(__dirname, 'node_modules', 'webextension-polyfill-ts'),
),
},
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
new HtmlWebpackPlugin(({
template: path.join(viewsPath, 'options.html'),
inject: 'body',
chunks: ['options'],
hash: true,
filename: 'options.html',
})),
new CopyPlugin({
patterns: [
{ from: path.join(srcPath, 'manifest.json'), to: 'manifest.json' },
{ from: path.join(srcPath, 'assets', 'icon.svg'), to: 'icon.svg' },
],
}),
],
devtool: 'source-map',
optimization: {
minimize: false,
},
};