-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.js
60 lines (57 loc) · 1.35 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 path = require('path')
const webpack = require('webpack')
const WebExtWebpackPlugin = require('webext-webpack-plugin').default
const CopyWebpackPlugin = require('copy-webpack-plugin');
if (process.env.API_USER && process.env.API_PASSWORD) {
var secrets = {
password: process.env.API_PASSWORD,
username: process.env.API_USERNAME
}
}
else {
try {
var secrets = require('./secrets.json')
}
catch (e) {
var secrets = require('./secrets.example.json')
console.log("WARNING: No API key defined in secrets.json. Using placeholder values.")
}
}
module.exports = (env, argv) => {
let config = {
module: {
rules: [
{
test: /\.css$/i,
use: 'raw-loader',
},
],
},
entry: {
'content': './src/content.js',
'background': './src/background.js'
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist')
},
mode: 'production',
plugins: [
new webpack.DefinePlugin({
'API_CONFIG': JSON.stringify(secrets)
}),
new CopyWebpackPlugin([
{from: 'manifest.json', to: 'manifest.json'},
]),
]
};
if (env && env.debug) {
config.plugins.push(
new WebExtWebpackPlugin({
sourceDir: path.resolve(__dirname),
startUrl: ['https://google.com/flights']
})
)
}
return config
}