Skip to content

Commit

Permalink
refactor: switch to new build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbert committed Dec 6, 2024
1 parent 5593e8c commit ebd25b8
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 156 deletions.
5 changes: 2 additions & 3 deletions components/data-badge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
],
"main": "dist/index.css",
"scripts": {
"build": "rollup -c ../rollup.config.mjs",
"build": "build-css-package",
"clean": "rimraf dist"
},
"devDependencies": {
"@utrecht/badge-css": "workspace:*",
"rollup": "4.18.0"
"@utrecht/build-utils-css": "workspace:*"
},
"keywords": [
"nl-design-system"
Expand Down
2 changes: 1 addition & 1 deletion packages/component-library-css/src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
@import "~@utrecht/combobox-css/src/index";
@import "~@utrecht/currency-data-css/src/index";
@import "~@utrecht/custom-checkbox-css/src/index";
@import "~@utrecht/data-badge/src/index";
@import "~@utrecht/data-badge-css/src/index";
@import "~@utrecht/data-list-css/src/index";
@import "~@utrecht/data-placeholder-css/src/index";
@import "~@utrecht/digid-button-css/src/index";
Expand Down
1 change: 1 addition & 0 deletions packages/component-library-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
"@utrecht/column-layout-css": "workspace:*",
"@utrecht/currency-data-css": "workspace:*",
"@utrecht/custom-checkbox-css": "workspace:*",
"@utrecht/data-badge-css": "workspace:*",
"@utrecht/data-badge-react": "workspace:*",
"@utrecht/data-list-css": "workspace:*",
"@utrecht/data-placeholder-css": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,4 @@
* Copyright (c) 2021-2024 Gemeente Utrecht
*/

import css from '@utrecht/data-badge-css/dist/index.mjs';
import { insertStyle } from './insert-style';
insertStyle(css);

export * from '../DataBadge';
export * from '@utrecht/data-badge-react/dist/css';
18 changes: 3 additions & 15 deletions packages/components-react/data-badge-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,25 @@
],
"sideEffects": false,
"scripts": {
"clean": "rimraf dist *.tsbuildinfo .rollup.cache coverage",
"build": "rollup --config ./rollup.config.mjs",
"clean": "rimraf dist *.tsbuildinfo .rollup.cache coverage",
"init": "init-react-package",
"test": "mkdir -p pages && jest --coverage --verbose",
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"@babel/plugin-transform-runtime": "7.24.7",
"@babel/preset-env": "7.24.7",
"@babel/preset-react": "7.24.7",
"@babel/preset-typescript": "7.24.7",
"@rollup/plugin-babel": "6.0.4",
"@rollup/plugin-commonjs": "26.0.1",
"@rollup/plugin-json": "6.1.0",
"@rollup/plugin-node-resolve": "15.2.3",
"@rollup/plugin-typescript": "12.1.0",
"@testing-library/dom": "8.20.1",
"@testing-library/jest-dom": "6.5.0",
"@testing-library/react": "16.0.1",
"@testing-library/user-event": "14.5.1",
"@types/jest": "29.5.13",
"@types/react": "18.3.3",
"@types/testing-library__jest-dom": "5.14.9",
"@utrecht/data-badge-css": "workspace:*",
"@utrecht/build-utils-react": "workspace:*",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"react": "18.3.1",
"rollup": "4.23.0",
"rollup-plugin-filesize": "10.0.0",
"rollup-plugin-node-externals": "7.1.2",
"rollup-plugin-peer-deps-external": "2.2.4",
"rollup-plugin-postcss": "4.0.2",
"typescript": "5.6.2"
},
"keywords": [
Expand Down
88 changes: 2 additions & 86 deletions packages/components-react/data-badge-react/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,87 +1,3 @@
import babel from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import resolve from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import { readFileSync } from 'fs';
import filesize from 'rollup-plugin-filesize';
import nodeExternal from 'rollup-plugin-node-externals';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import postcss from 'rollup-plugin-postcss';
import { createConfig } from '@utrecht/build-utils-react/src/rollup.mjs';

const packagePath = new URL('./package.json', import.meta.url).pathname;
const packageJson = JSON.parse(readFileSync(packagePath, 'utf8'));

/**
* @type {import('rollup').RollupOptions}
*/
export default [
{
input: './src/index.tsx',
output: [
{
file: packageJson.main,
format: 'cjs',
sourcemap: true,
},
{
file: packageJson.module,
format: 'es',
sourcemap: true,
},
],
plugins: [
peerDepsExternal(),
commonjs(),
nodeExternal(),
resolve({ browser: true }),
json(),
typescript({ tsconfig: './tsconfig.build.json' }),
babel({
presets: ['@babel/preset-react'],
babelHelpers: 'runtime',
exclude: ['node_modules/**', 'dist/**'],
extensions: ['.ts', '.tsx'],
inputSourceMap: true,
plugins: ['@babel/plugin-transform-runtime'],
}),
filesize(),
],
},
{
input: './src/css.tsx',
output: [
{
file: './dist/css.cjs',
format: 'cjs',
sourcemap: true,
},
{
file: './dist/css.mjs',
format: 'es',
sourcemap: true,
},
],
plugins: [
peerDepsExternal(),
commonjs(),
nodeExternal(),
resolve({ browser: true }),
json(),
postcss({
extensions: ['.css', '.scss'],
minimize: true,
}),
typescript({ tsconfig: './tsconfig.build.json' }),
babel({
presets: ['@babel/preset-react'],
babelHelpers: 'runtime',
exclude: ['node_modules/**', 'dist/**'],
extensions: ['.ts', '.tsx'],
inputSourceMap: true,
plugins: ['@babel/plugin-transform-runtime'],
}),
filesize(),
],
},
];
export default createConfig();
3 changes: 3 additions & 0 deletions packages/components-react/data-badge-react/src/css.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
*/

import '@utrecht/data-badge-css/src/index.scss';
import css from '@utrecht/data-badge-css/dist/index.mjs';
import { insertStyle } from './insert-style';
insertStyle(css);

export * from './index';
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const insertStyle = function (css: string) {
if (typeof document !== 'undefined') {
var head = document.head || document.getElementsByTagName('head')[0];
var style = document.createElement('style');
style.appendChild(document.createTextNode(css));
head.appendChild(style);
}
};
53 changes: 7 additions & 46 deletions pnpm-lock.yaml

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

0 comments on commit ebd25b8

Please sign in to comment.