-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathwebpack.config.js
73 lines (69 loc) · 2.17 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
// Copyright (c) 2020 The Brave Authors. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// you can obtain one at http://mozilla.org/MPL/2.0/.
const path = require('path')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const CopyPlugin = require('copy-webpack-plugin')
const rewardsDir = 'scripts/brave_rewards'
const allEntries = [
`${rewardsDir}/publisher/github/githubBase`,
`${rewardsDir}/publisher/github/githubAutoContribution`,
`${rewardsDir}/publisher/reddit/redditBase`,
`${rewardsDir}/publisher/reddit/redditAutoContribution`,
`${rewardsDir}/publisher/twitch/twitchBase`,
`${rewardsDir}/publisher/twitch/twitchAutoContribution`,
`${rewardsDir}/publisher/twitter/twitterBase`,
`${rewardsDir}/publisher/twitter/twitterAutoContribution`,
`${rewardsDir}/publisher/vimeo/vimeoBase`,
`${rewardsDir}/publisher/vimeo/vimeoAutoContribution`,
`${rewardsDir}/publisher/youtube/youtubeBase`,
`${rewardsDir}/publisher/youtube/youtubeAutoContribution`
]
// We use a bundler (webpack) since the browser does
// not support es-modules in content-scripts.
module.exports = (env, argv) => {
const config = {
devtool: argv.mode === 'development' ? 'inline-source-map' : false,
entry: allEntries.reduce((e, script) => {
e[script] = `./${script}`
return e
}, {}),
plugins: [
new CopyPlugin({
patterns: [
{ from: 'Greaselion.json' }
]
})
],
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [
{
test: /\.tsx?$/,
use: [{
loader: 'ts-loader',
options: {
onlyCompileBundledFiles: true,
allowTsInNodeModules: true
}
}]
}
]
},
resolve: {
extensions: [ '.tsx', '.ts', '.js' ]
}
}
// If we're watching, we don't want to clean out the output
// dir every incremental update.
if (!argv.watch) {
config.plugins.unshift(
new CleanWebpackPlugin()
)
}
return config
}