Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Bengeljo's avatar

js files that get build

Hey there, I am new to Laravel and looked at a few tutorials and are half way through the 30 day course that is provided. I am very happy that I ran into this since I am new to web dev and didn't use a framework before. Anyways. What I wanted to ask, I saw that the js scripts are "build" from the resources folder into the public/build/assets folder and I wanted to ask how I could add mine. Since I have a game that I want to transfer to the framework (a kind of quiz game) and I don't want to have people check on the js script or modify it easily to get solutions. I saw that it gets rewriten and it is hard to understand what happens in the app script when don't have the "clean" version.

Is there a way I can include mine in there ? I tried to just move them in there and tried to re run the npm run build command in the terminal but it only build the app.js and the app.css again.

Anybody knows how I can solve my problem?

0 likes
4 replies
puklipo's avatar

JS files that you don't want to build can be placed directly in public.

public/js/foo.js

<script src="{{ asset('js/foo.js') }}"></script>
DhPandya's avatar
DhPandya
Best Answer
Level 12

@bengeljo Basically there are two ways to import your custom script files to the build.

  1. Import your custom css and js within the app.js/app.css @import "./your_css.css" or import "./your_js.js"

  2. If your files are working as individual then specify it's within the vite.config.js

input: [
                'resources/css/app.css',
                'resources/js/app.js',
                'resources/css/your_custom.css',
                'resources/js/your_custom.js',
            ],
1 like
Bengeljo's avatar

@DhPandya That is what I have been looking for thanks a lot. I need them as individual since the game modes are all different.

Please or to participate in this conversation.