在Laravel 9中,我在哪里包括自定义JS和CSS文件?

发布于 2025-02-08 03:45:18 字数 545 浏览 1 评论 0原文

我正在手动下载这些CS和JS文件: https://github.com/1j01/os------ gui

我不确定我的Laravel 9应用程序中应该放置CSS和JS文件。

做什么的正确方法是什么?我应该只下载文件并将文件放在public目录中吗?但是,我不应该利用Laravel 9的混音来编译JS CSS文件,如果是这样,我该怎么做?

这是我要使用的文件列表:

css/layout.css
css/windows-98.css
css/windows-default.css
js/$Window.js
js/MenuBar.js
js/parse-theme.js
js/demo.js
js/jquery-3.3.1.js // i'll probably use v3.6.0 (or whatever is the latest version)

I'm manually downloading these CSS and JS files from: https://github.com/1j01/os-gui

I'm not sure where in my Laravel 9 app I should place the CSS and JS files.

What's the proper way to do it? Should I just download and place the files in the public directory? But shouldn't I be utilizing Laravel 9's Mix to compile the JS CSS files, and if so how can I go about doing that?

This is the list of files I want to use:

css/layout.css
css/windows-98.css
css/windows-default.css
js/$Window.js
js/MenuBar.js
js/parse-theme.js
js/demo.js
js/jquery-3.3.1.js // i'll probably use v3.6.0 (or whatever is the latest version)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

╰ゝ天使的微笑 2025-02-15 03:45:18

如果您希望这些文件得到优化和控制,并且也希望每个请求都不下载一堆CSS和JS文件,则应使用默认安装的Laravel Mix,

您应该将这些文件放入 /Resources文件夹中并将其编译为一个文件,忠实地,您可以使用混合purge插件将被清除/优化。

这在您的webpack.mix.js中真的很简单

mix.js('resources/js/app.js', 'public/js')
    .css('resources/css/app.css', 'public/css', [
        // and in your app.css you can @import every css you need to load 
    ]);

If you want those files to be optimized and controlled and also want that every request does not download a bunch of css and js files, you should use laravel mix which is installed by default

You should put those files inside /resources folder and compile them into a single file, adittionally you could purge with the mix purge plugin so your assets will be purged/optimized.

This is really simple in your webpack.mix.js

mix.js('resources/js/app.js', 'public/js')
    .css('resources/css/app.css', 'public/css', [
        // and in your app.css you can @import every css you need to load 
    ]);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文