简体   繁体   English

如何将 SASS/SCSS 文件和 CSS 文件组合成一个 laravel 组合中的单个 CSS 文件?

[英]How to combine SASS/SCSS files and CSS files into a single CSS file in laravel mix?

I'm trying to combine few SASS files and CSS files into a single CSS file in the Laravel mix but I could not find how.我正在尝试将几个 SASS 文件和 CSS 文件合并到 Laravel 组合中的单个 CSS 文件中,但我找不到如何组合。

here is a sample laravel mix that I'm trying to use which return errors:这是我尝试使用的示例 laravel 组合,它返回错误:

mix.js('resources/js/app.js', 'public/js')
    .sass('resources/scss/app.scss', 'public/css')
    .styles('resources/css/app.css', 'public/css');
  1. You can import the CSS file on the sass file, then compile only the main sass file if it's feasible.您可以在 sass 文件上导入 CSS 文件,如果可行,则只编译主要的 sass 文件。 found this which may help you: https://stackoverflow.com/questions/7111610/import-regular-css-file-in-scss-file#:~:text=It%20is%20now%20possible%20to,will%20import%20your%20file%20directly .发现这可能对你有帮助: https://stackoverflow.com/questions/7111610/import-regular-css-file-in-scss-file#:~:text=It%20is%20now%20possible%20to,will% 20import%20your%20file%20directly

  2. You can combine CSS files.您可以合并 CSS 个文件。 here is an example I have used.这是我用过的一个例子。 maybe you can compile sass to CSS and later combine using this method?也许您可以将 sass 编译为 CSS,然后使用此方法进行合并?

please check the sample请检查样品

//combine CSS    
    mix.styles([
        'resources/css/open-iconic-bootstrap.min.css',
        'resources/css/animate.css',
        'resources/css/bootstrap-datepicker.css',
    ], 'public/css/essentials.css');

for the completeness of the answer same kind of approach can be used to js files as follows,为了答案的完整性,可以对 js 文件使用如下相同的方法,

// combine required js files
mix.combine([
        'resources/js/vendors/jquery-migrate.min.js',
        'resources/js/vendors/jquery.easing.1.3.js',
        'resources/js/vendors/bootstrap-datepicker.js',
        'resources/js/vendors/scrollax.min.js'
    ], 'public/js/essentials.js');

use this approach on your webpack.mix.js在你的 webpack.mix.js 上使用这种方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM