使用Laravel Mix从动态Vue组件导入中排除.php文件

问题描述

我具有以下目录结构:

  • 资源/
    • js /
      • 组件/
        • App.vue
    • 插件/
      • plugin_1
        • Template.vue
        • Plugin.php
      • plugin_2
        • Template.vue
        • Plugin.php
      • ...
  • webpack.mix.js

我希望动态地和异步地加载插件(template.vue组件),所以在 App.vue 中,我这样做:

event = BeautifulSoup(response.text,'html.parser')
note = event.findAll('span',{'class': 'header-3'})

编译过程一直进行,但带有以下警告(每个插件1个警告):

const req = require.context('../../plugins/',true,/\.(vue)$/i)

req.keys().map(key => {
    const name = key.split('.')[1].replace(/^\/|\/$/g,'').toLowerCase().replace(/\//g,'-')

    // key.substring(2) = e.g. plugin_1/Template.vue
    return Vue.component(name,() => import('../../plugins/' + key.substring(2)))
})

webpack.mix.js(package.json:“ laravel-mix”:“ ^ 5.0.5”):


WARNING in ./resources/plugins/plugin_1/**Plugin.php** 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type,currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <?php
|
| namespace Resources\Plugins\plugin_1;
 @ ./resources/plugins lazy ^\.\/.*$ namespace object ./plugin_/**Plugin.php**
 @ ./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/App.vue?vue&type=script&lang=js&
 @ ./resources/js/components/App.vue?vue&type=script&lang=js&
 @ ./resources/js/components/App.vue
 @ ./resources/js/app.js
 @ multi ./resources/js/app.js ./resources/sass/app.scss

它怎么会尝试加载.php文件?我想: const mix = require('laravel-mix'); mix.js('resources/js/app.js','public/js'); mix.sass('resources/sass/app.scss','public/css'); 会排除这些文件吗?我想念什么?干杯!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...