misc cleanup before i sleep
This commit is contained in:
parent
c8fbcc14d1
commit
79f02f424d
40
README.md
40
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}`,
|
||||||
|
// ...
|
||||||
|
}));
|
||||||
|
|
3
index.ts
3
index.ts
|
@ -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
2
package-lock.json
generated
|
@ -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,
|
||||||
|
|
|
@ -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",
|
||||||
|
|
Loading…
Reference in a new issue