-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathwebpack.config.js
60 lines (54 loc) · 1.45 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
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
const _ = require('lodash');
const commonConfig = {
context: path.join(__dirname, "src"),
entry: {
options: "./options.js",
background: "./background.js",
'lib/content-script': "./lib/content-script.js"
},
output: {
path: path.join(__dirname, "dist"),
filename: "[name].js"
},
plugins: [ ]
};
function createConfig(env, browserVar, extraDomainPaths) {
let config = _.defaultsDeep(
{},
{
name: env,
output: {
path: path.join(__dirname, "dist", env),
}
},
commonConfig
);
let domains = _.concat(extraDomainPaths, [
'*://issues.jboss.org/*',
'*://*.apache.org/*',
'*://*.jira.com/*',
'*://*.atlassian.com/*',
'*://*.atlassian.net/*',
]).join('|');
config.plugins = _.concat(config.plugins, [
new webpack.DefinePlugin({
MD_TO_JIRA_BROWSER_TARGET: JSON.stringify(env),
MD_TO_JIRA_DEFAULT_DOMAINS: JSON.stringify(domains),
BROWSER_SDK: browserVar
}),
new CopyWebpackPlugin([
'options.html',
'icon*.png',
{ from: 'lib/J2M.js', to: 'lib/J2M.js' },
{ from: `manifest.${env}.json`, to: 'manifest.json' } // Chrome and Firefox don't agree on format :-/
]),
]);
return config;
}
module.exports = [
createConfig('firefox', 'browser', ['file:///*']),
createConfig('chrome', 'chrome', ['file://*'])
]