-
Notifications
You must be signed in to change notification settings - Fork 23
/
webpack.firefox.config.js
52 lines (46 loc) · 1.58 KB
/
webpack.firefox.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
const { v4: uuidv4 } = require("uuid")
const CopyWebpackPlugin = require("copy-webpack-plugin")
const { compact } = require("lodash/fp")
const isEmpty = require("lodash/isEmpty")
const baseConfig = require("./webpack.base.config")
const appliationId = process.env.APPLICATION_ID
module.exports = (env) => {
if (env.NODE_ENV === "production" && isEmpty(appliationId)) {
throw new Error("APPLICATION_ID is not set, set it in .env or as an environment variable")
}
const config = baseConfig(env)
config.plugins.unshift(
new CopyWebpackPlugin({
patterns: [
{
from: "src/manifest.firefox.json",
to: "manifest.json",
transform: function (content, _path) {
const manifest = JSON.parse(
content.toString().replace(/\[version\]/g, process.env.npm_package_version),
)
return Buffer.from(
JSON.stringify({
...manifest,
permissions: compact([
...manifest.permissions,
env.NODE_ENV === "development" && process.env.USE_LOCAL_MOCO === "true"
? "http://*.mocoapp.localhost/*"
: null,
]),
browser_specific_settings: {
gecko: {
id: appliationId || `{${uuidv4()}}`,
},
},
description: process.env.npm_package_description,
version: process.env.npm_package_version,
}),
)
},
},
],
}),
)
return config
}