Skip to content

Commit 30e61c7

Browse files
committed
Rewrite Croppie in TypeScript
1 parent 959a0a1 commit 30e61c7

File tree

10 files changed

+3252
-2
lines changed

10 files changed

+3252
-2
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
end_of_line = lf

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
npm-debug.log
33
node_modules/
44
bower_components
5-
/nbproject/private/
5+
/nbproject/private/
6+
.vscode/
7+
dist/

.prettierrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"arrowParens": "always",
3+
"bracketSpacing": true,
4+
"endOfLine": "lf",
5+
"printWidth": 80,
6+
"semi": true,
7+
"singleQuote": true,
8+
"trailingComma": "none",
9+
"tabWidth": 2,
10+
"useTabs": false
11+
}

build.ts

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import { rollup } from 'rollup';
2+
const { terser } = require('rollup-plugin-terser');
3+
const typescript = require('rollup-plugin-typescript');
4+
5+
const build = async () => {
6+
const buildEsm2015 = async () => {
7+
const esm2015Bundle = rollup({
8+
input: 'src/index.ts',
9+
plugins: [typescript()]
10+
});
11+
return (await esm2015Bundle).write({
12+
file: 'dist/esm2015/croppie.js',
13+
format: 'esm',
14+
sourcemap: true
15+
});
16+
};
17+
18+
const buildEsm5 = async () => {
19+
const esm5Bundle = rollup({
20+
input: 'src/index.ts',
21+
plugins: [
22+
typescript({
23+
target: 'es5',
24+
declaration: false
25+
})
26+
]
27+
});
28+
return (await esm5Bundle).write({
29+
file: 'dist/esm5/croppie.js',
30+
format: 'esm',
31+
sourcemap: true
32+
});
33+
};
34+
35+
const buildUmd = async () => {
36+
const umdBundle = rollup({
37+
input: 'src/index.ts',
38+
plugins: [
39+
typescript({
40+
target: 'es5'
41+
})
42+
]
43+
});
44+
return (await umdBundle).write({
45+
file: 'dist/bundles/croppie.js',
46+
format: 'umd',
47+
sourcemap: true,
48+
name: 'Croppie'
49+
});
50+
};
51+
52+
const buildUmdMinified = async () => {
53+
const umdMinifiedBundle = rollup({
54+
input: 'src/index.ts',
55+
plugins: [
56+
typescript({
57+
target: 'es5'
58+
}),
59+
terser()
60+
]
61+
});
62+
return (await umdMinifiedBundle).write({
63+
file: 'dist/bundles/croppie.min.js',
64+
format: 'umd',
65+
sourcemap: true,
66+
name: 'Croppie'
67+
});
68+
};
69+
70+
await buildEsm2015();
71+
await buildEsm5();
72+
await buildUmd();
73+
await buildUmdMinified();
74+
};
75+
76+
build().then((_) => console.log('Done'));

0 commit comments

Comments
 (0)