0

我有一个我继承的 Rails 5.1.4 应用程序部署到 Heroku。它正在使用带有 vuejs 的 webpacker,现在在部署到 Heroku 时遇到问题。Heroku 运行时收到以下消息rake assets:precompile:

remote:        [13] ./app/javascript/production-guarantee-component.vue 193 bytes {0} [built] [failed] [1 error]
remote:        [14] ./app/javascript/packs/tmp_dashboard.js 2.44 kB {1} [built]
remote:        + 4 hidden modules
remote:        ERROR in ./app/javascript/adder-dashboard.vue
remote:        Module parse failed: Unexpected token (1:0)
remote:        You may need an appropriate loader to handle this file type.
remote:        | <template>
remote:        |   <div class="col-md-12">
remote:        |       <adder-component v-for="category in categories" :category ="category"></adder-component>
remote:        @ ./app/javascript/packs/pricing_dashboard.js 16:0-52
remote:        ERROR in ./app/javascript/app.vue
remote:        Module parse failed: Unexpected token (1:

该代码在本地运行良好,Module parse failed对我来说甚至没有意义。什么是调试的好地方?

4

1 回答 1

0

通常node_modules被添加到.gitignore. 我建议您在本地生产环境中测试您的应用程序。运行RAILS_ENV=production bundle exec rake assets:precompile以在生产中预编译您的资产。

如果你正在安装 js 依赖项yarn,rails 预编译也应该触发yarn install,然后运行生产服务器rails s -e production并在本地环境中测试它

您还需要从 github 存储库中找到adder-dashboard.vue并阅读有关将 vue.js 与 rails 一起使用的文档

https://ksylvest.com/posts/2016-09-07/augmenting-a-ruby-on-rails-app-with-vue-js

https://rlafranchi.github.io/2016/03/09/vuejs-and-rails/

将 Dropzone.js 与 Vue.js 一起使用

https://coligo.io/real-time-analytics-with-nodejs-socketio-vuejs/

于 2017-12-21T08:02:41.017 回答