misc cleanup before i sleep

This commit is contained in:
Erin 2023-07-28 08:29:53 -04:00
parent c8fbcc14d1
commit 79f02f424d
4 changed files with 43 additions and 4 deletions

View file

@ -1 +1,39 @@
# rollup-create-webext-config # rollup-build-webext-config
Simplify Rollup configuration for browser extensions by pulling script entry
points and other asset paths straight from your `manifest.json`. Recognizes
manifest versions 2 and 3.
## Usage
### Targeting a single platform
```js
// rollup.config.js
import {buildConfig} from 'rollup-build-webext-config';
import {nodeResolve} from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
export default buildConfig({
manifest: 'path/to/your/manifest.json',
outDir: 'build',
sourcemap: 'inline',
plugins: [
nodeResolve(),
commonjs(),
],
});
```
### Targeting multiple platforms
```js
// rollup.config.js
import {buildConfig} from 'rollup-build-webext-config';
export default ['chromium', 'firefox'].flatMap(platform => buildConfig({
manifest: `manifest-${platform}.json`,
outDir: `build/${platform}`,
// ...
}));

View file

@ -47,7 +47,8 @@ export function buildConfig ({
// actual manifest file we generate // actual manifest file we generate
const uniqueFileNameSegmentCache = new Map([['\0', 'manifest.json']]); const uniqueFileNameSegmentCache = new Map([['\0', 'manifest.json']]);
function ensureUniquePath (filepath: string, ext = extname(filepath).slice(1)) { function ensureUniquePath (filepath: string, ext = extname(filepath).slice(1)) {
// console.log('getting segment for', filepath); // TODO: this function is hell there's gotta be a better way to do literally
// all of this
const cached = uniqueFileNameSegmentCache.get(filepath); const cached = uniqueFileNameSegmentCache.get(filepath);
if (cached) { if (cached) {
return cached; return cached;

2
package-lock.json generated
View file

@ -1,5 +1,5 @@
{ {
"name": "rollup-create-webext-config", "name": "rollup-build-webext-config",
"version": "0.0.0", "version": "0.0.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,

View file

@ -1,5 +1,5 @@
{ {
"name": "rollup-create-webext-config", "name": "rollup-build-webext-config",
"version": "0.0.0", "version": "0.0.0",
"main": "build/index.js", "main": "build/index.js",
"type": "module", "type": "module",