Skip to content

Commit

Permalink
Inject umd croppie at build time
Browse files Browse the repository at this point in the history
  • Loading branch information
ericnewcomer committed Feb 8, 2024
1 parent 5a4dea1 commit bba0096
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
3 changes: 3 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ const baseConfig = createSpaConfig({
'<link rel="preload"',
'<link rel="modulepreload"'
);

// inject croppie
html = '<script src="{{STATIC_URL}}croppie/croppie.js"></script>' + html;
}

return html.replace(
Expand Down
7 changes: 3 additions & 4 deletions src/imagepicker/ImagePicker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable @typescript-eslint/no-this-alias */
import { html, css, PropertyValueMap } from 'lit';
import 'croppie/croppie.js';
import { CroppieCSS } from './CroppieCSS';
import { property } from 'lit/decorators.js';
import { Icon } from '../vectoricon';
Expand Down Expand Up @@ -166,11 +165,11 @@ export class ImagePicker extends FormElement {
wrapper.removeChild(wrapper.firstChild);
}
this.showCroppie = true;
const croppie = document.createElement('div');
wrapper.appendChild(croppie);
const ele = document.createElement('div');
wrapper.appendChild(ele);

const Croppie = (window as any).Croppie;
this.croppie = new Croppie(croppie, {
this.croppie = new Croppie(ele, {
enableExif: true,
viewport: {
width: 300,
Expand Down
11 changes: 7 additions & 4 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<!doctype html>
<html lang="en">
<head></head>
<body>
<script type="module" src="../out-tsc/temba-components.js"></script>
</body>

<head></head>

<body>
<script type="module" src="../out-tsc/temba-components.js"></script>
</body>

</html>

0 comments on commit bba0096

Please sign in to comment.