-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
80 lines (73 loc) · 2.19 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
require('dotenv').config()
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ZipPlugin = require('zip-webpack-plugin');
const WebpackWebExt = require('webpack-webext-plugin');
const browser = process.env.BROWSER;
const firefoxIssuer = process.env.FIREFOX_JWT_ISSUER;
const firefoxSecret = process.env.FIREFOX_JWT_SECRET;
const browserBuilds = [
{
browser: 'chrome',
plugin: new ZipPlugin({
path: '.',
filename: `${browser}.zip`,
include: [/\.*$/]
})
},
{
browser: 'opera',
plugin: new ZipPlugin({
path: '.',
filename: `${browser}.zip`,
include: [/\.*$/]
})
},
{
browser: 'firefox',
plugin: new WebpackWebExt({
runOnce: false,
argv: [
'sign',
'--api-key', firefoxIssuer,
'--api-secret', firefoxSecret,
'-a', 'dist/',
'-s', 'dist/'],
}),
}
];
const defaultBrowserBuild = browserBuilds[0].plugin;
const selectedBuilds = browserBuilds.filter((plugin) => browser === plugin.browser);
const browserBuildPlugin = selectedBuilds.length !== 0 ? selectedBuilds[0].plugin : defaultBrowserBuild;
const jsTransformationModule = {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: '/node_modules/',
options: {
presets: ['es2015']
}
}
]
};
const jsModule = browser !== 'dev' ? jsTransformationModule : {};
module.exports = {
entry: {
'hate-love': './src/scripts/hate-love.js',
popup: './src/scripts/popup.js'
},
output: {
path: __dirname + '/dist',
filename: '[name].js'
},
module: jsModule,
plugins: [
new CopyWebpackPlugin([
{ from: `./src/manifests/${browser}.json` , to: 'manifest.json' },
{ from: './src/styles/styles.css' , to: 'styles.css' },
{ from: './src/img/icon.png' , to: 'icon.png' },
{ from: './src/views/popup.html' , to: 'popup.html' }
]),
browserBuildPlugin
]
};