Skip to content
This repository was archived by the owner on May 19, 2023. It is now read-only.

Commit 2f5978e

Browse files
committed
build: simplify rollup config
1 parent d1ccbc6 commit 2f5978e

File tree

4 files changed

+35
-86
lines changed

4 files changed

+35
-86
lines changed

.vscode/settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
// Use the project's typescript version
33
"typescript.tsdk": "node_modules/typescript/lib",
4-
"editor.formatOnPaste": true,
54
"cSpell.diagnosticLevel": "Hint",
65
// Use prettier to format typescript, javascript and JSON files
76
"[typescript]": {

rollup.config.js

Lines changed: 34 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ import ts from '@wessberg/rollup-plugin-ts';
77
import filesize from 'rollup-plugin-filesize';
88
import { terser } from 'rollup-plugin-terser';
99

10-
const name = 'Lucia';
11-
12-
const generateConfig = (input, config) => ({
10+
const suite = (input, output) => ({
1311
input,
1412
plugins: [
1513
eslint(),
@@ -22,62 +20,48 @@ const generateConfig = (input, config) => ({
2220
}),
2321
beep(),
2422
],
25-
output: config.output,
23+
output,
2624
onwarn: () => {},
2725
});
2826

29-
export const build = (input, config) => {
30-
const buildOutput = [];
31-
32-
config.output.forEach((fileName) => {
33-
const isMinifiedBuildOutput = /min/gi.test(fileName);
34-
const defaultBuildOptions = {
35-
file: fileName,
36-
format: config.format,
37-
name,
38-
strict: true,
39-
};
40-
41-
if (isMinifiedBuildOutput) {
42-
// Production build
43-
buildOutput.push({
44-
...defaultBuildOptions,
45-
plugins: [
46-
terser(),
47-
filesize({
48-
showBrotliSize: true,
49-
showMinifiedSize: false,
50-
showBeforeSizes: 'release',
51-
showGzippedSize: false,
52-
}),
53-
],
54-
});
55-
} else {
56-
// Development build
57-
buildOutput.push(defaultBuildOptions);
58-
}
59-
});
60-
61-
return generateConfig(input, {
62-
output: buildOutput,
63-
});
64-
};
27+
export const unit = ({ file, format, minify }) => ({
28+
file,
29+
format,
30+
name: 'Lucia',
31+
strict: true,
32+
plugins: minify
33+
? [
34+
terser(),
35+
filesize({
36+
showBrotliSize: true,
37+
showMinifiedSize: false,
38+
showBeforeSizes: 'release',
39+
showGzippedSize: false,
40+
}),
41+
]
42+
: [],
43+
});
6544

66-
export default [
67-
build('./src/index.ts', {
68-
output: ['dist/lucia.esm.js'],
45+
export default suite('./src/index.ts', [
46+
unit({
47+
file: './dist/lucia.esm.js',
6948
format: 'esm',
7049
}),
71-
build('./src/index.ts', {
72-
output: ['dist/lucia.cjs.js'],
50+
unit({
51+
file: './dist/lucia.cjs.js',
7352
format: 'cjs',
7453
}),
75-
build('./src/index.ts', {
76-
output: ['dist/lucia.umd.js'],
54+
unit({
55+
file: './dist/lucia.umd.js',
7756
format: 'umd',
7857
}),
79-
build('./src/index.ts', {
80-
output: ['dist/lucia.js', 'dist/lucia.min.js'],
58+
unit({
59+
file: './dist/lucia.js',
60+
format: 'iife',
61+
}),
62+
unit({
63+
file: './dist/lucia.min.js',
8164
format: 'iife',
65+
minify: true,
8266
}),
83-
];
67+
]);

scripts/dev.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ if [ ! -f index.html ]; then
2020
echo -e "$content" >> index.html
2121
info "Couldn't find an \`index.html\` file at root, creating one for you..."
2222
fi
23-
npx vite --host
23+
vite --host

yarn.lock

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,14 +1634,6 @@
16341634
"@typescript-eslint/typescript-estree" "4.25.0"
16351635
debug "^4.1.1"
16361636

1637-
"@typescript-eslint/[email protected]":
1638-
version "4.24.0"
1639-
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.24.0.tgz#38088216f0eaf235fa30ed8cabf6948ec734f359"
1640-
integrity sha512-9+WYJGDnuC9VtYLqBhcSuM7du75fyCS/ypC8c5g7Sdw7pGL4NDTbeH38eJPfzIydCHZDoOgjloxSAA3+4l/zsA==
1641-
dependencies:
1642-
"@typescript-eslint/types" "4.24.0"
1643-
"@typescript-eslint/visitor-keys" "4.24.0"
1644-
16451637
"@typescript-eslint/[email protected]":
16461638
version "4.25.0"
16471639
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.25.0.tgz#9d86a5bcc46ef40acd03d85ad4e908e5aab8d4ca"
@@ -1650,29 +1642,11 @@
16501642
"@typescript-eslint/types" "4.25.0"
16511643
"@typescript-eslint/visitor-keys" "4.25.0"
16521644

1653-
"@typescript-eslint/[email protected]":
1654-
version "4.24.0"
1655-
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.24.0.tgz#6d0cca2048cbda4e265e0c4db9c2a62aaad8228c"
1656-
integrity sha512-tkZUBgDQKdvfs8L47LaqxojKDE+mIUmOzdz7r+u+U54l3GDkTpEbQ1Jp3cNqqAU9vMUCBA1fitsIhm7yN0vx9Q==
1657-
16581645
"@typescript-eslint/[email protected]":
16591646
version "4.25.0"
16601647
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.25.0.tgz#0e444a5c5e3c22d7ffa5e16e0e60510b3de5af87"
16611648
integrity sha512-+CNINNvl00OkW6wEsi32wU5MhHti2J25TJsJJqgQmJu3B3dYDBcmOxcE5w9cgoM13TrdE/5ND2HoEnBohasxRQ==
16621649

1663-
"@typescript-eslint/[email protected]":
1664-
version "4.24.0"
1665-
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.24.0.tgz#b49249679a98014d8b03e8d4b70864b950e3c90f"
1666-
integrity sha512-kBDitL/by/HK7g8CYLT7aKpAwlR8doshfWz8d71j97n5kUa5caHWvY0RvEUEanL/EqBJoANev8Xc/mQ6LLwXGA==
1667-
dependencies:
1668-
"@typescript-eslint/types" "4.24.0"
1669-
"@typescript-eslint/visitor-keys" "4.24.0"
1670-
debug "^4.1.1"
1671-
globby "^11.0.1"
1672-
is-glob "^4.0.1"
1673-
semver "^7.3.2"
1674-
tsutils "^3.17.1"
1675-
16761650
"@typescript-eslint/[email protected]":
16771651
version "4.25.0"
16781652
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.25.0.tgz#942e4e25888736bff5b360d9b0b61e013d0cfa25"
@@ -1686,14 +1660,6 @@
16861660
semver "^7.3.2"
16871661
tsutils "^3.17.1"
16881662

1689-
"@typescript-eslint/[email protected]":
1690-
version "4.24.0"
1691-
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.24.0.tgz#a8fafdc76cad4e04a681a945fbbac4e35e98e297"
1692-
integrity sha512-4ox1sjmGHIxjEDBnMCtWFFhErXtKA1Ec0sBpuz0fqf3P+g3JFGyTxxbF06byw0FRsPnnbq44cKivH7Ks1/0s6g==
1693-
dependencies:
1694-
"@typescript-eslint/types" "4.24.0"
1695-
eslint-visitor-keys "^2.0.0"
1696-
16971663
"@typescript-eslint/[email protected]":
16981664
version "4.25.0"
16991665
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.25.0.tgz#863e7ed23da4287c5b469b13223255d0fde6aaa7"

0 commit comments

Comments
 (0)