diff --git a/README.md b/README.md index adedbe7..8df3f2d 100644 --- a/README.md +++ b/README.md @@ -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}`, + // ... +})); diff --git a/index.ts b/index.ts index 25da230..5c96b71 100644 --- a/index.ts +++ b/index.ts @@ -47,7 +47,8 @@ export function buildConfig ({ // actual manifest file we generate const uniqueFileNameSegmentCache = new Map([['\0', 'manifest.json']]); 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); if (cached) { return cached; diff --git a/package-lock.json b/package-lock.json index facc821..43dd0e7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "rollup-create-webext-config", + "name": "rollup-build-webext-config", "version": "0.0.0", "lockfileVersion": 3, "requires": true, diff --git a/package.json b/package.json index 241c3cf..8181254 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "rollup-create-webext-config", + "name": "rollup-build-webext-config", "version": "0.0.0", "main": "build/index.js", "type": "module",