Ruby on rails 为什么我的console.log语句在使用webpack和rails时停止工作

Ruby on rails 为什么我的console.log语句在使用webpack和rails时停止工作,ruby-on-rails,webpack,Ruby On Rails,Webpack,我使用webpack安装了一个新的rails应用程序。 当我运行应用程序时,默认的console.log显示良好 /* eslint no-console:0 */ // This file is automatically compiled by Webpack, along with any other files // present in this directory. You're encouraged to place your actual application logic in

我使用webpack安装了一个新的rails应用程序。 当我运行应用程序时,默认的console.log显示良好

/* eslint no-console:0 */
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.
//
// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
// layout file, like app/views/layouts/application.html.erb

console.log('Hello World from Webpacker')
当我重新启动rails时,console.log就会消失

有什么冲突吗

总之,console.log消息在我的新rails应用程序中与--wepack一起工作。当我这样做的时候:

  • 在/app/javascript/packs文件夹中添加application.scss
  • 在我的布局中引用application.scss

  • console.log消息停止工作。我启动/停止rails,但仍然没有console.log消息。

    这确实是我今天遇到的问题

    对我来说,在
    app/javascript/packs
    文件夹中创建一个子文件夹是可行的

    我的目录现在如下所示:

    • app/javascript/packs/stylesheets/application.scss
    • app/javascript/packs/application.js
    在我的
    应用程序中.haml

    • =javascript\u pack\u标记“应用程序”
    • =stylesheet\u pack\u标记“stylesheets/application”
    如果我将
    application.scss
    放在与
    application.js
    相同的目录中,
    console.log()
    将按照您的建议停止工作

    我的猜测是,由于两者都命名为
    application
    ,webpacker会混淆在
    javascript\u pack\u tag
    stylesheet\u pack\u tag
    上必须加载哪个文件


    这就是为什么将其移动到另一个目录将解决我的问题。

    您是否在布局中添加了
    javascript\u pack\u标记“application”
    ?是的,显示console.log。当我在布局中添加application.scss和stylesheet\u pack\u标记时,由于某种原因,它就消失了。您找到解决方案了吗?谢谢。因为这个application.scss问题,我损失了一天的时间。我永远也想不到。我想知道我关注的是哪个博客!
    /app/javascript/packs/application.scss