Skip to content

Commit

Permalink
chore: add rollup toolking plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
meel-io committed Jan 24, 2024
1 parent 54d0068 commit f88337d
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ workflows:
filters:
branches:
only: /(^renovate-.*|^nori/.*)/
tags:
only: /^v\d+\.\d+\.\d+(-.+)?/
- tool-kit/setup:
name: tool-kit/setup-<< matrix.executor >>
requires:
Expand Down
23 changes: 23 additions & 0 deletions .toolkitrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
plugins:
- "@dotcom-tool-kit/babel"
- "@dotcom-tool-kit/component"
- "@dotcom-tool-kit/jest"
- "@dotcom-tool-kit/eslint"
- "@dotcom-tool-kit/lint-staged"
- "./toolkit/rollup"
hooks:
build:local:
- Rollup
build:ci:
- Rollup
test:local:
- Eslint
- JestLocal
test:ci:
- Eslint
- JestCI
options:
"@dotcom-tool-kit/circleci":
nodeVersion:
- '18.16'
- '16.20'
50 changes: 28 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
"license": "MIT",
"repository": "Financial-Times/n-tracking.git",
"scripts": {
"clean": "rm -rf ./dist",
"build": "dotcom-tool-kit build:local",
"prepare": "npm run build",
"test": "dotcom-tool-kit test:local",
"start": "dotcom-tool-kit run:local"
},
Expand All @@ -33,7 +31,7 @@
"jest-environment-jsdom-fifteen": "^1.0.0",
"jsdom": "^15.1.0",
"react": "^16.9.0",
"rollup": "^1.31.0",
"rollup": "^2.71.1",
"rollup-plugin-babel": "^4.3.3",
"seed-random": "^2.2.0"
},
Expand Down
4 changes: 4 additions & 0 deletions toolkit/rollup/.toolkitrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
hooks:
'build:local': Rollup
'build:ci': Rollup
'build:remote': Rollup
21 changes: 21 additions & 0 deletions toolkit/rollup/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const { Task } = require('@dotcom-tool-kit/types');
const rollup = require('rollup');
const loadConfigFile = require('rollup/dist/loadConfigFile');
const path = require('path');

class Rollup extends Task {
async run () {
const config = path.join(process.cwd(), 'rollup.config.js');
const { options, warnings } = await loadConfigFile(config);

// print any config warnings to the console
warnings.flush();

for (const optionsEntry of options) {
const bundle = await rollup.rollup(optionsEntry);
await Promise.all(optionsEntry.output.map(bundle.write));
}
}
}

exports.tasks = [Rollup];

0 comments on commit f88337d

Please sign in to comment.