-
Notifications
You must be signed in to change notification settings - Fork 26
/
webpack.chrome.config.js
39 lines (35 loc) · 1.13 KB
/
webpack.chrome.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
const CopyWebpackPlugin = require("copy-webpack-plugin")
const { compact } = require("lodash/fp")
const baseConfig = require("./webpack.base.config")
module.exports = (env) => {
const config = baseConfig(env)
config.plugins.unshift(
new CopyWebpackPlugin({
patterns: [
{
from: "src/manifest.chrome.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,
host_permissions: compact([
...manifest.host_permissions,
env.NODE_ENV === "development" && process.env.USE_LOCAL_MOCO === "true"
? "http://*.mocoapp.localhost/*"
: null,
]),
description: process.env.npm_package_description,
version: process.env.npm_package_version,
}),
)
},
},
],
}),
)
return config
}