Skip to content

Commit

Permalink
the new build script
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyraspopov committed Oct 17, 2024
1 parent e57a3f7 commit 47bded8
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"name": "oscillation",
"version": "0.3.0",
"type": "module",
"scripts": {
"test": "playwright test",
"build": "rollup --config rollup.config.js"
},
"prettier": {
"printWidth": 100,
"trailingComma": "all",
Expand All @@ -9,6 +15,7 @@
"@playwright/test": "^1.48.1",
"prettier": "^3.3.3",
"rollup": "^4.24.0",
"rollup-plugin-copy": "^3.5.0",
"rollwright": "^0.0.7"
}
}
40 changes: 40 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { defineConfig } from "rollup";
import copy from "rollup-plugin-copy";

export default defineConfig({
input: "./oscillation.js",
output: { dir: "build" },
plugins: [
copy({
targets: [
{ src: ["LICENSE", "oscillation.d.ts"], dest: "build" },
{ src: "package.json", dest: "build", transform: generatePackageJson },
],
}),
],
});

function generatePackageJson(contents) {
let pkg = JSON.parse(contents.toString());
let newPkg = {
name: pkg.name,
version: pkg.version,
description: pkg.description,
license: pkg.license,
author: pkg.author,
homepage: pkg.homepage,
repository: pkg.repository,
type: "module",
main: "./oscillation.js",
module: "./oscillation.js",
exports: {
".": "./oscillation.js",
},
files: ["*.js", "*.d.ts"],
sideEffects: false,
keywords: pkg.keywords,
dependencies: pkg.dependencies,
peerDependencies: pkg.peerDependencies,
};
return JSON.stringify(newPkg, null, 2);
}

0 comments on commit 47bded8

Please sign in to comment.