Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manifest v3 initial rework #96

Merged
merged 18 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
537 changes: 295 additions & 242 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
"build": "NODE_ENV=production node ./scripts/build.js && node ./scripts/zip.js"
},
"devDependencies": {
"@discoveryjs/discovery": "1.0.0-beta.83",
"@discoveryjs/json-ext": "^0.5.7",
"@discoveryjs/discovery": "1.0.0-beta.87",
"css-tree": "^2.3.1",
"esbuild": "^0.20.1",
"esbuild": "^0.24.0",
"eslint": "^8.50.0",
"jszip": "^3.10.1",
"mime": "^3.0.0"
Expand Down
30 changes: 10 additions & 20 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
'safari'
];

function processCss(css, outdir, resdir) {

Check failure on line 20 in scripts/build.js

View workflow job for this annotation

GitHub Actions / build (16.x)

'processCss' is defined but never used. Allowed unused vars must match /^React$/u
// CSS post-process
const ast = csstree.parse(css);

Expand Down Expand Up @@ -49,24 +49,20 @@

fs.rmSync(outdir, { recursive: true, force: true }); // rm -rf
fs.mkdirSync(outdir, { recursive: true });
fs.writeFileSync(outdir + '/manifest.json', manifest(browser));
fs.writeFileSync(path.join(outdir, 'manifest.json'), manifest(browser));

copyFile(path.join(indir, 'sandbox.html'), outdir);
copyFiles(path.join(indir, 'icons'), outdir);

// build bundle
const result = await esbuild.build({
await esbuild.build({
entryPoints: [
path.join(indir, 'background.js'),
path.join(indir, 'content/discovery.css'),
path.join(indir, 'content/preloader.css'),
path.join(indir, 'content/discovery.js'),
path.join(indir, 'content/discovery-esm.js'),
path.join(indir, 'content/init.js')
{ in: path.join(indir, 'content/init.js'), out: 'init' },
path.join(indir, 'sandbox.js')
],
format: 'esm',
bundle: true,
minify: true,
write: false,
outdir,
define: {
global: 'window'
Expand All @@ -77,16 +73,6 @@
'.md': 'text'
}
});

for (const file of result.outputFiles) {
const content = path.extname(file.path) === '.css'
? processCss(file.text, outdir, 'assets')
: file.contents;

const filePath = path.join(outdir, path.basename(file.path));

fs.writeFileSync(filePath, content);
}
}

const buildAll = async function() {
Expand Down Expand Up @@ -131,6 +117,10 @@
}
})();

function copyFile(filepath, dest) {
fs.copyFileSync(filepath, path.join(dest, path.basename(filepath)));
}

function copyFiles(src, dest) {
fs.mkdirSync(dest, { recursive: true });

Expand All @@ -139,6 +129,6 @@
copyFiles(path.join(src, p), path.join(dest, path.basename(src)))
);
} else {
fs.copyFileSync(src, path.join(dest, path.basename(src)));
copyFile(src, dest);
}
}
1 change: 0 additions & 1 deletion src/content/discovery-esm.js

This file was deleted.

1 change: 0 additions & 1 deletion src/content/discovery.css

This file was deleted.

7 changes: 0 additions & 7 deletions src/content/discovery.js

This file was deleted.

Loading
Loading