3

I am working on a laravel 8 project for learning purposes. I am new in jetstream, inertia.js here I can not understand how to add or link external CSS/js files in innertia.js.

Someone, please help me.

Antu Paul
  • 161
  • 2
  • 5
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Apr 11 '22 at 14:58
  • 1
    did you find the solution? if yes, Please post. I am also working with larvael 9 + inertia _vite. – Neha Sep 20 '22 at 12:25

4 Answers4

0

you can just add this on the main page layout :

        <script src="{{ asset('js/data.js') }}"></script>

then add your js file in this path : public/js.yourfile.js

a bcd
  • 188
  • 9
0
// Layout.vue

import { Head } from '@inertiajs/inertia-vue3'

<Head>
  <title>My app</title>
  <meta head-key="description" name="description" content="This is the default description" />
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<script src="your script location"></script>

</Head>

// About.vue

import { Head } from '@inertiajs/inertia-vue3'

<Head>
  <title>About - My app</title>
  <meta head-key="description" name="description" content="This is a page specific description" />
</Head>
Vijay Kanaujia
  • 439
  • 4
  • 9
0

Actually, there are many ways to link CSS/JS Here I share a very simple way to link

first, you have to store your external file in the public directory for your project.

then in your index file

("asset" automatically locate public folder that's why you don't need to mention that.)

Note: same process for CSS file.

Antu Paul
  • 161
  • 2
  • 5
0

Here is How I Import external css,js

.resources/js/app.js

import '../admin_scripts/css/style.css';
import '../admin_scripts/vendor/apexcharts/apexcharts.min.js';

Script/Files Location .resources/admin_scripts

It Works Fine .

Sublan Mustafa
  • 199
  • 1
  • 6