Skip to content

Commit

Permalink
Rewrite Croppie in TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
sarunint committed Dec 5, 2018
1 parent 959a0a1 commit 681edbc
Show file tree
Hide file tree
Showing 10 changed files with 3,252 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
npm-debug.log
node_modules/
bower_components
/nbproject/private/
/nbproject/private/
.vscode/
dist/
11 changes: 11 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"endOfLine": "lf",
"printWidth": 80,
"semi": true,
"singleQuote": true,
"trailingComma": "none",
"tabWidth": 2,
"useTabs": false
}
76 changes: 76 additions & 0 deletions build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { rollup } from 'rollup';
const { terser } = require('rollup-plugin-terser');
const typescript = require('rollup-plugin-typescript');

const build = async () => {
const buildEsm2015 = async () => {
const esm2015Bundle = rollup({
input: 'src/index.ts',
plugins: [typescript()]
});
return (await esm2015Bundle).write({
file: 'dist/esm2015/croppie.js',
format: 'esm',
sourcemap: true
});
};

const buildEsm5 = async () => {
const esm5Bundle = rollup({
input: 'src/index.ts',
plugins: [
typescript({
target: 'es5',
declaration: false
})
]
});
return (await esm5Bundle).write({
file: 'dist/esm5/croppie.js',
format: 'esm',
sourcemap: true
});
};

const buildUmd = async () => {
const umdBundle = rollup({
input: 'src/index.ts',
plugins: [
typescript({
target: 'es5'
})
]
});
return (await umdBundle).write({
file: 'dist/bundles/croppie.js',
format: 'umd',
sourcemap: true,
name: 'Croppie'
});
};

const buildUmdMinified = async () => {
const umdMinifiedBundle = rollup({
input: 'src/index.ts',
plugins: [
typescript({
target: 'es5'
}),
terser()
]
});
return (await umdMinifiedBundle).write({
file: 'dist/bundles/croppie.min.js',
format: 'umd',
sourcemap: true,
name: 'Croppie'
});
};

await buildEsm2015();
await buildEsm5();
await buildUmd();
await buildUmdMinified();
};

build().then((_) => console.log('Done'));
Loading

0 comments on commit 681edbc

Please sign in to comment.