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>
feature/default_network_editable
kumavis 4 years ago committed by GitHub
parent 2dadf4374a
commit 952adbce44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .eslintrc.js
  2. 15
      app/background.html
  3. 9
      app/manifest/_base.json
  4. 24
      development/build/manifest.js
  5. 23
      development/build/static.js
  6. 0
      development/chromereload.js
  7. 1
      development/empty.js

@ -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/**',

@ -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);
};

@ -0,0 +1 @@
// this file intentionally left blank : )
Loading…
Cancel
Save