WebPack encore configuration for VueJS



当我从带有 VueJS 的基本 symfony 应用程序和 symfony 提供的捆绑包 Webpack encore 加载页面时,我遇到以下错误

[Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.

所以我需要用这个将 VueJS 的别名更改为 webpack:

resolve: {
  alias: {
    vue: 'vue/dist/vue.js'
  }
}

但是我没有在 Webpack Encore 中找到任何更改此设置的内容。

网络包安可 : http://symfony.com/doc/current/frontend.html

将此行添加到您的 package.json 中可以解决问题吗?

"browser": {
   "vue": "vue/dist/vue.common"
}

这是捆绑器的特殊字段。所以在这里,我们将 vue 的默认仅运行时版本替换为其编译器包含的构建。

当您为浏览器字段指定单个字符串时,它将 替换主模块并成为模块入口点。主字段指定 模块的入口点,因此通过替换它,您可以替换 打包器打包模块以供浏览器使用时的入口点。

请参阅规格:https://github.com/defunctzombie/package-browser-field-spec

最新更新