使用webpack.mix编译js文件时,mix.scripts在laravel 5.5上不起作用

时间:2017-12-25 11:11:21

标签: javascript php webpack laravel-5.5

我正在使用Laravel 5.5,在webpack.mix文件中,mix.styles函数运行正常,我完全编译css文件,但mix.scripts不编译js文件我在文档中发现mix.babel它的方法签名与scripts.mix相同所以我使用它但没有改变

这是我的webpack.mix.js文件

let mix = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.js('resources/assets/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css');


mix.styles([
    'resources/assets/css/libs/blog-post.css',
    'resources/assets/css/libs/bootstrap.css',
    'resources/assets/css/libs/font-awesome.css',
    'resources/assets/css/libs/metisMenu.css',
    'resources/assets/css/libs/sb-admin-2.css',
    'resources/assets/css/libs/test.css'

], 'public/css/libs.css');

mix.babel([
    'resources/assets/js/libs/jquery.js',
    'resources/assets/js/libs/bootstrap.js',
    'resources/assets/js/libs/metisMenu.js',
    'resources/assets/js/sb-admin-2.js',
    'resources/assets/js/libs/scripts.js',
    'resources/assets/js/libs/test.js'

], 'public/js/libs.js');

1 个答案:

答案 0 :(得分:1)

webpack.mix文件没有问题,mix.babel工作得很好,问题是我使用的是Ubuntu,当libs.js文件被创建时,它只是默认读取它阻止了编译,所以我不得不改变它来读写chmod。