Consuming Dexie as a module - dexie

I'm just getting started with Dexie. I encountered an error I do not understand attempting to follow the Short Version example of Consuming Dexie as a module. I have the following source files:
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Dexie Test</title>
<style>
</style>
</head>
<body>
<script src="./mytest.js" type="module"></script>
</body>
</html>
mydb.js
import Dexie from './dexie.js';
const db = new Dexie('myDb');
db.version(1).stores({
friends: 'name, age'
});
export default db;
mytest.js
import db from './mydb.js';
console.log(db.name);
When I run this from a local web server, I get the following error:
Uncaught SyntaxError: The requested module './dexie.js' does not provide an export named 'default'

To use the ES module version of Dexie you will need dexie.mjs instead of dexie.js from https://unpkg.com/dexie#^3.0.0-rc.1/dist/dexie.mjs. Or if you pick it from node_modules, make sure you've installed dexie#next or dexie#^3.0.0-rc.1.

Related

Error finding assets when running laravel artisan in host

I'm using Laravel 8 and trying to host my project to public localhost using php artisan serve --host '0.0.0.0' --port 8080 so I can access it from another device, but got the error message:
GET <ip>:8080/css/app.css net::ERR_CONTENT_LENGTH_MISMATCH 200 (OK)
GET <ip>:8080/js/app.js net::ERR_CONTENT_LENGTH_MISMATCH 200 (OK)
I've used laravel mix and stored them in public/css and public/js. Here is my base laravel blade template code.
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="{{ asset('css/app.css') }}" rel="stylesheet" type="text/css">
<title>{{ config('app.name') }}</title>
</head>
<body>
#include('layouts.navbar')
#yield('content')
<script src="{{ asset('js/app.js') }}" defer></script>
</body>
</html>
I've also tried adding ASSET_URL=public in .env file, but still not working. Any help would be much appreciated, thank's in advanced!

Cannot load assets on live server using the mix helper function

I am trying to run my application via a tunnel service (https://localtunnel.github.io/www/), but it sets the relative path to local which makes it so that my assets can't get loaded.
What I have tried:
changing the mix helper to the assets helper -> works, but makes me unable to use the npm hot reload function. I would like to make use of this.
My blade file:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{csrf_token()}}">
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
<title>Laravel Vue Ecommerce</title>
<link href=" {{ mix('css/app.css') }}" rel="stylesheet">
</head>
<body>
<div id="app">
<app></app>
</div>
<script src="{{ mix('js/bootstrap.js') }}"></script>
<script src="{{ mix('js/app.js') }}"></script>
</body>
</html>
webpack.mix.js:
mix.js('resources/js/app.js', 'public/js').vue()
.sass('resources/sass/app.scss', 'public/css')
.sourceMaps()
The errors:
GET https://localhost:8080/css/app.css net::ERR_BLOCKED_BY_CLIENT
tame-dog-60.loca.lt/:16
GET https://localhost:8080/js/bootstrap.js net::ERR_BLOCKED_BY_CLIENT
tame-dog-60.loca.lt/:17
GET https://localhost:8080/js/app.js net::ERR_BLOCKED_BY_CLIENT

Laravel - Fresh VueJS and Inertia app giving error: Do not mount Vue to <html> or <body> - mount to normal elements instead

I have just done a fresh install of inertia on an app with vuejs (v2) and am getting this error:
[Vue warn]: Do not mount Vue to <html> or <body> - mount to normal elements instead.
But I don't see why it's trying to mount on those elements? As far as I can tell I've followed the inertia installation guide....
web.php
Route::get('test', function(){return \Inertia\Inertia::render('master');});
app-ihf.js
import { App, plugin } from '#inertiajs/inertia-vue'
import Vue from 'vue'
import { InertiaProgress } from '#inertiajs/progress'
Vue.use(plugin)
const el = document.getElementById('app')
new Vue({
render: h => h(App, {
props: {
initialPage: JSON.parse(el.dataset.page),
resolveComponent: name => require(`./Pages/${name}`).default,
},
}),
}).$mount(el)
InertiaProgress.init()
master.blade.php
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/css/app-ihf.css">
<script src="{{ mix('/js/app-ihf.js') }}"></script>
</head>
<body>
#inertia
</body>
</html>
Can anyone see what's going wrong here? This is the html when you visit that route
<html><head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/css/app-ihf.css?id=fc17ae1fae0b57440a59">
<script src="/js/app-ihf.js?id=fa7eba2a2c660c498a3e"></script>
</head>
<body>
<div id="app" data-page="{"component":"master","props":{"errors":{}},"url":"\/test","version":"3993c0d73e25e92aa0e15607a6c438ef"}"></div>
</body></html>
I had the exact same issue and it's because I didn't put defer into the script tag so the JavaScript in app.js was running before the id="app" element existed on the page.
So in your case you need:
<script src="{{ mix('/js/app-ihf.js') }}" defer></script>

Laravel Dompdf taking too long to download pdf

I want to make a pdf invoice from blade template using Dompdf in Laravel 5.5.
The problem is when clicking on the download button the page is loading and after ~3 min i the pdf starts downloading.
Why is it taking so long?
the download link
<i class="fa fa-file-pdf-o"></i> Download Invoice
web route:
Route::get('/order/download-invoice/{OrderID}', 'Admin\AdminOrderController#downloadOrderInvoice')->name('admin.download-invoice');
a simple template (invoice.blade.php)
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other
head content must come *after* these tags -->
<title>Invoice</title>
<link rel="stylesheet" href="{{ asset('css/bootstrap.min.css') }}" media="screen">
</head>
<body>
<div>{{ $invoice->InvoiceTitle }} </div>
</body>
</html>
donwload invoice controller function:
use Barryvdh\DomPDF\Facade as PDF;
public function downloadOrderInvoice($OrderID){
$invoice = Invoice::where('OrderID', $OrderID)->first();
$pdf = PDF::loadView('invoice.invoice', compact('invoice'))->setPaper('a4', 'landscape');
return $pdf->download('invoice.pdf');
}
What i did wrong? Did i miss something?
UPDATE
clear the header and using EXTERNAL CDN bootstrap works.
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
Why is not using the local bootstrap using asset???
<link href="{{asset('css/bootstrap.min.css')}}" rel="stylesheet">

laravel and webpack transform reactjs not reloading

I am having trouble getting hot reloading to work with my laravel app.
//laravel homepage
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Laravel</title>
</head>
<body>
<div id="root"></div>
<?php
if (App::isLocal()):
?>
<script type="text/javascript" src="http://localhost:3000/static/bundle.js"></script>
<?php else: ?>
<script type="text/javascript" src="/dist/bundle.js"></script>
<?php endif; ?>
</body>
</html>
When I go to my homestead laravel backend page (localhost:8000), everything works fine, but there's no hot reloading when I change react components.
When I go directly to the dev-server http://localhost:3000 I get hot reloading.
I am using the react transform boilerplate: https://github.com/gaearon/react-transform-boilerplate
How can I get the backend laravel page to reload the bundle?
change
src="http://localhost:3000/static/bundle.js"
to
src="{{url('static/bundle.js)'}}"
and
src="/dist/bundle.js"
to
src="{{url('/dist/bundle.js')}}"

Resources