forked from Morikko/sync-tab-groups
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
115 lines (107 loc) · 2.7 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const devConfig = require('./webpack.dev.config');
const prodConfig = require('./webpack.prod.config');
function copy(path) {
return {
from: path,
to: path,
};
}
function multipleCopy(...paths) {
return paths.map(copy);
}
const config = {
context: path.resolve(__dirname, './extension'),
entry: {
'background': './background/background.js',
'popup/popup': './popup/popup.js',
'options/option-page': './options/option-page.js',
'manage/manage-groups': './manage/manage-groups-controller.jsx',
'tabpages/lazytab/lazytab': './tabpages/lazytab/lazytab.js',
'tabpages/privileged-tab/privileged-tab': './tabpages/privileged-tab/privileged-tab.jsx',
'tabpages/selector-groups/selector-groups-controller': './tabpages/selector-groups/selector-groups-controller.jsx',
'tabpages/shortcut-help/shortcut-help': './tabpages/shortcut-help/shortcut-help.jsx',
},
output: {
filename: '[name].js',
sourceMapFilename: '[name].js.map',
},
resolve: {
extensions: ['.js', '.jsx'],
},
watchOptions: {
ignored: /node_modules/,
},
optimization: {
minimizer: [
new TerserPlugin({
cache: true,
parallel: true,
sourceMap: true,
terserOptions: {
ecma: 8,
compress: {
drop_console: true,
},
},
}),
],
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ['babel-loader'],
},
{
test: /\.(scss|css)$/,
use: [
require.resolve('style-loader'),
//MiniCssExtractPlugin.loader,
{
loader: require.resolve('css-loader'),
},
{
loader: require.resolve('sass-loader'),
},
],
},
{
test: /.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
use: [{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: '/fonts/',
publicPath: '/fonts/',
},
}],
},
],
},
plugins: [
new CopyWebpackPlugin(
multipleCopy('_locales', 'manifest.json')
.concat([
{from: '**/*.html'},
{from: '**/*.css'},
{from: '**/*.png'},
])
),
],
};
module.exports = (env, argv) => {
let envConfig;
if (argv.mode === 'development') {
envConfig = devConfig;
}
if (argv.mode === 'production') {
envConfig = prodConfig;
}
return merge(config, envConfig);
};