mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 01:47:00 +01:00
Build - refactor background process to use html (#10769)
* build - declare background as html * build - fill in empty file when a missing file is expected * lint - fix * Update development/build/manifest.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Update development/build/manifest.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> Co-authored-by: Mark Stacey <markjstacey@gmail.com>
This commit is contained in:
parent
2dadf4374a
commit
952adbce44
@ -26,7 +26,7 @@ module.exports = {
|
||||
'test-*/**',
|
||||
'docs/**',
|
||||
'coverage/',
|
||||
'app/scripts/chromereload.js',
|
||||
'development/chromereload.js',
|
||||
'app/vendor/**',
|
||||
'test/e2e/send-eth-with-private-key-test/**',
|
||||
'nyc_output/**',
|
||||
|
15
app/background.html
Normal file
15
app/background.html
Normal file
@ -0,0 +1,15 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<script src="./globalthis.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="./initSentry.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="./lockdown.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="./runLockdown.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="./bg-libs.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="./background.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="./chromereload.js" type="text/javascript" charset="utf-8"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,14 +1,7 @@
|
||||
{
|
||||
"author": "https://metamask.io",
|
||||
"background": {
|
||||
"scripts": [
|
||||
"globalthis.js",
|
||||
"initSentry.js",
|
||||
"lockdown.js",
|
||||
"runLockdown.js",
|
||||
"bg-libs.js",
|
||||
"background.js"
|
||||
],
|
||||
"page": "background.html",
|
||||
"persistent": true
|
||||
},
|
||||
"browser_action": {
|
||||
|
@ -8,10 +8,6 @@ const { createTask, composeSeries } = require('./task');
|
||||
|
||||
module.exports = createManifestTasks;
|
||||
|
||||
const scriptsToExcludeFromBackgroundDevBuild = {
|
||||
'bg-libs.js': true,
|
||||
};
|
||||
|
||||
function createManifestTasks({ browserPlatforms }) {
|
||||
// merge base manifest with per-platform manifests
|
||||
const prepPlatforms = async () => {
|
||||
@ -35,29 +31,13 @@ function createManifestTasks({ browserPlatforms }) {
|
||||
);
|
||||
};
|
||||
|
||||
// dev: remove bg-libs, add chromereload, add perms
|
||||
// dev: add perms
|
||||
const envDev = createTaskForModifyManifestForEnvironment((manifest) => {
|
||||
const scripts = manifest.background.scripts.filter(
|
||||
(scriptName) => !scriptsToExcludeFromBackgroundDevBuild[scriptName],
|
||||
);
|
||||
scripts.push('chromereload.js');
|
||||
manifest.background = {
|
||||
...manifest.background,
|
||||
scripts,
|
||||
};
|
||||
manifest.permissions = [...manifest.permissions, 'webRequestBlocking'];
|
||||
});
|
||||
|
||||
// testDev: remove bg-libs, add perms
|
||||
// testDev: add perms
|
||||
const envTestDev = createTaskForModifyManifestForEnvironment((manifest) => {
|
||||
const scripts = manifest.background.scripts.filter(
|
||||
(scriptName) => !scriptsToExcludeFromBackgroundDevBuild[scriptName],
|
||||
);
|
||||
scripts.push('chromereload.js');
|
||||
manifest.background = {
|
||||
...manifest.background,
|
||||
scripts,
|
||||
};
|
||||
manifest.permissions = [
|
||||
...manifest.permissions,
|
||||
'webRequestBlocking',
|
||||
|
@ -80,13 +80,34 @@ const copyTargetsDev = [
|
||||
pattern: '/chromereload.js',
|
||||
dest: ``,
|
||||
},
|
||||
// empty files to suppress missing file errors
|
||||
{
|
||||
src: './development/',
|
||||
pattern: '/empty.js',
|
||||
dest: `bg-libs.js`,
|
||||
},
|
||||
{
|
||||
src: './development/',
|
||||
pattern: '/empty.js',
|
||||
dest: `ui-libs.js`,
|
||||
},
|
||||
];
|
||||
|
||||
const copyTargetsProd = [
|
||||
...copyTargets,
|
||||
// empty files to suppress missing file errors
|
||||
{
|
||||
src: './development/',
|
||||
pattern: '/empty.js',
|
||||
dest: `chromereload.js`,
|
||||
},
|
||||
];
|
||||
|
||||
function createStaticAssetTasks({ livereload, browserPlatforms }) {
|
||||
const prod = createTask(
|
||||
'static:prod',
|
||||
composeSeries(
|
||||
...copyTargets.map((target) => {
|
||||
...copyTargetsProd.map((target) => {
|
||||
return async function copyStaticAssets() {
|
||||
await performCopy(target);
|
||||
};
|
||||
|
1
development/empty.js
Normal file
1
development/empty.js
Normal file
@ -0,0 +1 @@
|
||||
// this file intentionally left blank : )
|
Loading…
Reference in New Issue
Block a user