optimize webpack bundles

This commit is contained in:
Alex Turchyn
2023-06-24 18:31:12 +03:00
parent 2c0bed9823
commit 8bb6ff7ab3
10 changed files with 91 additions and 18 deletions
@@ -40,8 +40,6 @@
</template>
<script>
import SignaturePad from 'signature_pad'
import { DirectUpload } from '@rails/activestorage'
import { IconReload } from '@tabler/icons-vue'
export default {
@@ -75,10 +73,13 @@ export default {
isSignatureStarted: false
}
},
mounted () {
async mounted () {
this.$refs.canvas.width = this.$refs.canvas.parentNode.clientWidth
this.$refs.canvas.height = this.$refs.canvas.parentNode.clientWidth / 3
import('@rails/activestorage')
const { default: SignaturePad } = await import('signature_pad')
this.pad = new SignaturePad(this.$refs.canvas)
this.pad.addEventListener('beginStroke', () => {
@@ -94,11 +95,13 @@ export default {
this.isSignatureStarted = false
},
submit () {
async submit () {
if (this.modelValue) {
return Promise.resolve({})
}
const { DirectUpload } = await import('@rails/activestorage')
return new Promise((resolve) => {
this.$refs.canvas.toBlob((blob) => {
const file = new File([blob], 'signature.png', { type: 'image/png' })