@ogs-gmbh/rolldown-plugin-assets 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/handlers.d.ts +14 -0
- package/handlers.d.ts.map +1 -0
- package/handlers.js +37 -0
- package/handlers.js.map +1 -0
- package/package.json +56 -0
- package/plugin.d.ts +24 -0
- package/plugin.d.ts.map +1 -0
- package/plugin.js +59 -0
- package/plugin.js.map +1 -0
- package/public-api.d.ts +8 -0
- package/public-api.js +8 -0
- package/types.d.ts +37 -0
- package/types.d.ts.map +1 -0
- package/types.js +6 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 — present OGS Gesellschaft für Datenverarbeitung und Systemberatung mbH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/handlers.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) 2026 — present OGS Gesellschaft für Datenverarbeitung und Systemberatung mbH
|
|
4
|
+
* Licensed under MIT (See https://github.com/OGS-GmbH/rolldown-plugin-assets/LICENSE)
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { PluginContext } from "rolldown";
|
|
8
|
+
|
|
9
|
+
//#region src/handlers.d.ts
|
|
10
|
+
declare function handleFile(this: PluginContext, cwd: string, from: string, to: string): void;
|
|
11
|
+
declare function handleDirectory(this: PluginContext, cwd: string, from: string, to: string): void;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { handleDirectory, handleFile };
|
|
14
|
+
//# sourceMappingURL=handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlers.d.ts","names":[],"sources":["../../src/handlers.ts"],"mappings":";;;;;;;;;iBAIS,UAAA,CAAW,IAAA,EAAM,aAAA,EAAe,GAAA,UAAa,IAAA,UAAc,EAAA;AAAA,iBAe3D,eAAA,CAAgB,IAAA,EAAM,aAAA,EAAe,GAAA,UAAa,IAAA,UAAc,EAAA"}
|
package/handlers.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) 2026 — present OGS Gesellschaft für Datenverarbeitung und Systemberatung mbH
|
|
4
|
+
* Licensed under MIT (See https://github.com/OGS-GmbH/rolldown-plugin-assets/LICENSE)
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import fs from "node:fs";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
//#region src/handlers.ts
|
|
10
|
+
function handleFile(cwd, from, to) {
|
|
11
|
+
const fromPath = path.join(cwd, from);
|
|
12
|
+
const source = fs.readFileSync(fromPath, { encoding: "utf8" });
|
|
13
|
+
this.emitFile({
|
|
14
|
+
type: "asset",
|
|
15
|
+
fileName: to,
|
|
16
|
+
originalFileName: from,
|
|
17
|
+
source
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function handleDirectory(cwd, from, to) {
|
|
21
|
+
const fromPath = path.join(cwd, from);
|
|
22
|
+
const files = fs.readdirSync(fromPath, {
|
|
23
|
+
recursive: true,
|
|
24
|
+
encoding: "utf8"
|
|
25
|
+
});
|
|
26
|
+
for (const file of files) {
|
|
27
|
+
const fromPathWithFile = path.join(fromPath, file);
|
|
28
|
+
if (!fs.statSync(fromPathWithFile).isFile()) continue;
|
|
29
|
+
const fromWithFile = path.join(from, file);
|
|
30
|
+
const toWithFile = path.join(to, file);
|
|
31
|
+
handleFile.call(this, cwd, fromWithFile, toWithFile);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { handleDirectory, handleFile };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=handlers.js.map
|
package/handlers.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlers.js","names":[],"sources":["../../src/handlers.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { PluginContext } from \"rolldown\";\n\nfunction handleFile(this: PluginContext, cwd: string, from: string, to: string) {\n const fromPath = path.join(cwd, from);\n\n const source = fs.readFileSync(fromPath, {\n encoding: \"utf8\"\n });\n\n this.emitFile({\n type: \"asset\",\n fileName: to,\n originalFileName: from,\n source\n });\n}\n\nfunction handleDirectory(this: PluginContext, cwd: string, from: string, to: string) {\n const fromPath = path.join(cwd, from);\n\n const files = fs.readdirSync(fromPath, {\n recursive: true,\n encoding: \"utf8\"\n });\n\n for (const file of files) {\n const fromPathWithFile = path.join(fromPath, file);\n const stats = fs.statSync(fromPathWithFile);\n\n if (!stats.isFile()) continue;\n\n const fromWithFile = path.join(from, file);\n const toWithFile = path.join(to, file);\n\n handleFile.call(this, cwd, fromWithFile, toWithFile);\n }\n}\n\nexport { handleFile, handleDirectory };\n"],"mappings":";;;;;;;;;AAIA,SAAS,WAAgC,KAAa,MAAc,IAAY;CAC9E,MAAM,WAAW,KAAK,KAAK,KAAK,KAAK;CAErC,MAAM,SAAS,GAAG,aAAa,UAAU,EACvC,UAAU,QACX,CAAC;AAEF,MAAK,SAAS;EACZ,MAAM;EACN,UAAU;EACV,kBAAkB;EAClB;EACD,CAAC;;AAGJ,SAAS,gBAAqC,KAAa,MAAc,IAAY;CACnF,MAAM,WAAW,KAAK,KAAK,KAAK,KAAK;CAErC,MAAM,QAAQ,GAAG,YAAY,UAAU;EACrC,WAAW;EACX,UAAU;EACX,CAAC;AAEF,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,mBAAmB,KAAK,KAAK,UAAU,KAAK;AAGlD,MAAI,CAFU,GAAG,SAAS,iBAAiB,CAEhC,QAAQ,CAAE;EAErB,MAAM,eAAe,KAAK,KAAK,MAAM,KAAK;EAC1C,MAAM,aAAa,KAAK,KAAK,IAAI,KAAK;AAEtC,aAAW,KAAK,MAAM,KAAK,cAAc,WAAW"}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ogs-gmbh/rolldown-plugin-assets",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A Rolldown plugin that emits static assets (files and directories) to the output directory during the build process.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"assets",
|
|
7
|
+
"build",
|
|
8
|
+
"bundler",
|
|
9
|
+
"plugin",
|
|
10
|
+
"rolldown",
|
|
11
|
+
"rolldown-plugin",
|
|
12
|
+
"static-assets"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": "OGS GmbH",
|
|
16
|
+
"contributors": [
|
|
17
|
+
{
|
|
18
|
+
"name": "Simon Kovtyk",
|
|
19
|
+
"email": "simon@kovtyk.com",
|
|
20
|
+
"url": "https://simonkov.dev"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"type": "module",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"rolldown": "1.0.0-rc.13"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@commitlint/cli": "^20.5.0",
|
|
29
|
+
"@commitlint/config-conventional": "^20.5.0",
|
|
30
|
+
"@commitlint/prompt-cli": "^20.5.0",
|
|
31
|
+
"@ogs-gmbh/oxlint-presets": "^1.0.5",
|
|
32
|
+
"@ogs-gmbh/rolldown-plugin-package-json": "^1.1.0",
|
|
33
|
+
"@ogs-gmbh/vitepress-plugin-sidebar": "^1.0.3",
|
|
34
|
+
"@ogs-gmbh/vitepress-theme": "^1.1.0",
|
|
35
|
+
"@types/node": "^25.5.0",
|
|
36
|
+
"husky": "^9.1.7",
|
|
37
|
+
"lint-staged": "^16.4.0",
|
|
38
|
+
"oxfmt": "^0.42.0",
|
|
39
|
+
"oxlint": "^1.58.0",
|
|
40
|
+
"sass-embedded": "^1.98.0",
|
|
41
|
+
"tsdown": "^0.21.7",
|
|
42
|
+
"typedoc": "^0.28.18",
|
|
43
|
+
"typedoc-plugin-frontmatter": "^1.3.1",
|
|
44
|
+
"typedoc-plugin-markdown": "^4.11.0",
|
|
45
|
+
"typescript": "^5.9.3",
|
|
46
|
+
"vitepress": "^1.6.4",
|
|
47
|
+
"vitepress-plugin-group-icons": "^1.7.3"
|
|
48
|
+
},
|
|
49
|
+
"homepage": "https://ogs-gmbh.github.io/rolldown-plugin-assets",
|
|
50
|
+
"bugs": "https://github.com/OGS-GmbH/rolldown-plugin-assets/issues",
|
|
51
|
+
"repository": "https://github.com/OGS-GmbH/rolldown-plugin-assets",
|
|
52
|
+
"exports": {
|
|
53
|
+
"types": "./public-api.d.ts",
|
|
54
|
+
"default": "./public-api.js"
|
|
55
|
+
}
|
|
56
|
+
}
|
package/plugin.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) 2026 — present OGS Gesellschaft für Datenverarbeitung und Systemberatung mbH
|
|
4
|
+
* Licensed under MIT (See https://github.com/OGS-GmbH/rolldown-plugin-assets/LICENSE)
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Options } from "./types.js";
|
|
8
|
+
import { Plugin } from "rolldown";
|
|
9
|
+
|
|
10
|
+
//#region src/plugin.d.ts
|
|
11
|
+
/**
|
|
12
|
+
* A Rollup plugin that emits assets
|
|
13
|
+
*
|
|
14
|
+
* @param options - An `Object` to configure {@link Options} for the plugin's behavior.
|
|
15
|
+
* @returns A Rollup plugin that emits assets.
|
|
16
|
+
*
|
|
17
|
+
* @since 1.0.0
|
|
18
|
+
* @author Simon Kovtyk
|
|
19
|
+
* @category Plugin
|
|
20
|
+
*/
|
|
21
|
+
declare function assetsPlugin(options: Options): Plugin;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { assetsPlugin };
|
|
24
|
+
//# sourceMappingURL=plugin.d.ts.map
|
package/plugin.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","names":[],"sources":["../../src/plugin.ts"],"mappings":";;;;;;;;;;;;AAKqC;;;;;;;;iBAY5B,YAAA,CAAa,OAAA,EAAS,OAAA,GAAU,MAAA"}
|
package/plugin.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) 2026 — present OGS Gesellschaft für Datenverarbeitung und Systemberatung mbH
|
|
4
|
+
* Licensed under MIT (See https://github.com/OGS-GmbH/rolldown-plugin-assets/LICENSE)
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import fs from "node:fs";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import process from "node:process";
|
|
10
|
+
import { handleDirectory, handleFile } from "./handlers.js";
|
|
11
|
+
//#region src/plugin.ts
|
|
12
|
+
/**
|
|
13
|
+
* A Rollup plugin that emits assets
|
|
14
|
+
*
|
|
15
|
+
* @param options - An `Object` to configure {@link Options} for the plugin's behavior.
|
|
16
|
+
* @returns A Rollup plugin that emits assets.
|
|
17
|
+
*
|
|
18
|
+
* @since 1.0.0
|
|
19
|
+
* @author Simon Kovtyk
|
|
20
|
+
* @category Plugin
|
|
21
|
+
*/
|
|
22
|
+
function assetsPlugin(options) {
|
|
23
|
+
const cwd = process.cwd();
|
|
24
|
+
return {
|
|
25
|
+
name: "assets-plugin",
|
|
26
|
+
generateBundle: function() {
|
|
27
|
+
for (const asset of options) {
|
|
28
|
+
let from;
|
|
29
|
+
let to;
|
|
30
|
+
if (typeof asset === "string") {
|
|
31
|
+
from = asset;
|
|
32
|
+
to = asset;
|
|
33
|
+
} else {
|
|
34
|
+
from = asset[0];
|
|
35
|
+
to = asset[1];
|
|
36
|
+
}
|
|
37
|
+
const fromPath = path.join(cwd, from);
|
|
38
|
+
let stats;
|
|
39
|
+
try {
|
|
40
|
+
stats = fs.statSync(fromPath);
|
|
41
|
+
} catch {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (stats.isDirectory()) {
|
|
45
|
+
handleDirectory.call(this, cwd, from, to);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (stats.isFile()) {
|
|
49
|
+
handleFile.call(this, cwd, from, to);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
export { assetsPlugin };
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=plugin.js.map
|
package/plugin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","names":[],"sources":["../../src/plugin.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport process from \"node:process\";\nimport { Plugin, PluginContext } from \"rolldown\";\nimport { handleDirectory, handleFile } from \"./handlers.js\";\nimport { Options } from \"./types.js\";\n\n/**\n * A Rollup plugin that emits assets\n *\n * @param options - An `Object` to configure {@link Options} for the plugin's behavior.\n * @returns A Rollup plugin that emits assets.\n *\n * @since 1.0.0\n * @author Simon Kovtyk\n * @category Plugin\n */\nfunction assetsPlugin(options: Options): Plugin {\n const cwd = process.cwd();\n\n return {\n name: \"assets-plugin\",\n generateBundle: function (this: PluginContext) {\n for (const asset of options) {\n let from;\n let to;\n\n if (typeof asset === \"string\") {\n from = asset;\n to = asset;\n } else {\n from = asset[0];\n to = asset[1];\n }\n\n const fromPath = path.join(cwd, from);\n let stats;\n\n try {\n stats = fs.statSync(fromPath);\n } catch {\n continue;\n }\n\n if (stats.isDirectory()) {\n handleDirectory.call(this, cwd, from, to);\n\n continue;\n }\n\n if (stats.isFile()) {\n handleFile.call(this, cwd, from, to);\n\n continue;\n }\n }\n }\n };\n}\n\nexport { assetsPlugin };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAiBA,SAAS,aAAa,SAA0B;CAC9C,MAAM,MAAM,QAAQ,KAAK;AAEzB,QAAO;EACL,MAAM;EACN,gBAAgB,WAA+B;AAC7C,QAAK,MAAM,SAAS,SAAS;IAC3B,IAAI;IACJ,IAAI;AAEJ,QAAI,OAAO,UAAU,UAAU;AAC7B,YAAO;AACP,UAAK;WACA;AACL,YAAO,MAAM;AACb,UAAK,MAAM;;IAGb,MAAM,WAAW,KAAK,KAAK,KAAK,KAAK;IACrC,IAAI;AAEJ,QAAI;AACF,aAAQ,GAAG,SAAS,SAAS;YACvB;AACN;;AAGF,QAAI,MAAM,aAAa,EAAE;AACvB,qBAAgB,KAAK,MAAM,KAAK,MAAM,GAAG;AAEzC;;AAGF,QAAI,MAAM,QAAQ,EAAE;AAClB,gBAAW,KAAK,MAAM,KAAK,MAAM,GAAG;AAEpC;;;;EAIP"}
|
package/public-api.d.ts
ADDED
package/public-api.js
ADDED
package/types.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) 2026 — present OGS Gesellschaft für Datenverarbeitung und Systemberatung mbH
|
|
4
|
+
* Licensed under MIT (See https://github.com/OGS-GmbH/rolldown-plugin-assets/LICENSE)
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
//#region src/types.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* An asset described as path to it.
|
|
10
|
+
*
|
|
11
|
+
* @author Simon Kovtyk
|
|
12
|
+
* @since 1.0.0
|
|
13
|
+
* @category Types
|
|
14
|
+
*/
|
|
15
|
+
type Asset = string;
|
|
16
|
+
/**
|
|
17
|
+
* An `Array` that describes the source and destination paths for the asset.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* The first item of the `Array` is the source path and relative to `process.cwd`. The second `Array` item is the destination path, that is relative to Rolldown's output directory.
|
|
21
|
+
*
|
|
22
|
+
* @author Simon Kovtyk
|
|
23
|
+
* @since 1.0.0
|
|
24
|
+
* @category Types
|
|
25
|
+
*/
|
|
26
|
+
type AssetDirection = [string, string];
|
|
27
|
+
/**
|
|
28
|
+
* Options for the plugin. See {@link Asset} and {@link AssetDirection} for more details.
|
|
29
|
+
*
|
|
30
|
+
* @author Simon Kovtyk
|
|
31
|
+
* @since 1.0.0
|
|
32
|
+
* @category Types
|
|
33
|
+
*/
|
|
34
|
+
type Options = Array<Asset | AssetDirection>;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { type Asset, type AssetDirection, type Options };
|
|
37
|
+
//# sourceMappingURL=types.d.ts.map
|
package/types.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/types.ts"],"mappings":";;;;;;;;;;;;;AAOU;KAAL,KAAA;;;;AAYc;;;;;;;KAAd,cAAA;;;;;;;;KASA,OAAA,GAAU,KAAA,CAAM,KAAA,GAAQ,cAAA"}
|