stylesheet_pack_tag在带有webpacker gem的rails 5.1中找不到app / javascript / src / application.css

五里旺:

当我尝试使用webpacker在新的Rails 5.1应用程序中加载页面时,收到此错误。我希望webpacker也能处理CSS。

Started GET "/" for ::1 at 2017-09-01 12:20:23 -0400
Processing by HomeController#welcome as HTML
  Rendering home/welcome.html.erb within layouts/application
  Rendered home/welcome.html.erb within layouts/application (0.4ms)
Completed 500 Internal Server Error in 28ms



ActionView::Template::Error (Webpacker can't find application.css in /Users/myusername/Documents/testing-ground/myapp/public/packs/manifest.json. Possible causes:
1. You want to set wepbacker.yml value of compile to true for your environment
   unless you are using the `webpack -w` or the webpack-dev-server.
2. Webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your Webpack configuration is not creating a manifest.
Your manifest contains:
{
  "application.js": "/packs/application-1ba6db9cf5c0fb48c785.js",
  "hello_react.js": "/packs/hello_react-812cbb4d606734bec7a9.js"
}
):
     7:     <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload' %>
     8:     <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
     9:     <%= javascript_pack_tag 'application' %>
    10: <%= stylesheet_pack_tag 'application' %>
    11:   </head>
    12:
    13:   <body>

app/views/layouts/application.html.erb:10:in `_app_views_layouts_application_html_erb__1178607493020013329_70339213085820'

我在./bin/webpack-dev-server旁边rails server我使用以下方法创建了应用程序:

rails new myapp --webpack bundle bundle exec rails webpacker:install:react

我只有一个CSS文件app/javascript/src/application.css(使我感到有些不对劲的文字。将css放在javascript目录中似乎是不合适的。)

我只定义了一个根路由root to: 'home#welcome'

这是 app/views/layouts/application.html.erb

<!DOCTYPE html>
<html>
  <head>
    <title>Myapp</title>
    <%= csrf_meta_tags %>

    <%= javascript_pack_tag 'application' %>
    <%= stylesheet_pack_tag 'application' %>
  </head>

  <body>
    <%= yield %>
  </body>
</html>

这是我的config/webpacker.yml(我也尝试过false在开发中设置编译

# Note: You must restart bin/webpack-dev-server for changes to take effect

default: &default
  source_path: app/javascript
  source_entry_path: packs
  public_output_path: packs
  cache_path: tmp/cache/webpacker

  # Additional paths webpack should lookup modules
  # ['app/assets', 'engine/foo/app/assets']
  resolved_paths: []

  # Reload manifest.json on all requests so we reload latest compiled packs
  cache_manifest: false

  extensions:
    - .coffee
    - .erb
    - .js
    - .jsx
    - .ts
    - .vue
    - .sass
    - .scss
    - .css
    - .png
    - .svg
    - .gif
    - .jpeg
    - .jpg

development:
  <<: *default
  compile: true

  dev_server:
    host: localhost
    port: 3035
    hmr: false
    https: false

test:
  <<: *default
  compile: true

  # Compile test packs to a separate directory
  public_output_path: packs-test

production:
  <<: *default

  # Production demands on precompilation of packs prior to booting for performance.
  compile: false

  # Cache manifest.json for performance
  cache_manifest: true

我不想在前面添加太多细节,以防它们分散注意力,从而有所帮助。请提出其他要求,我将添加到我的问题中。谢谢!

蛇 :

在您的application.js中:

import "path to application.css"

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Rails 5 + Webpacker +反应。在系统测试中找不到application.js

Sprockets :: FileNotFound:在Rails App中找不到类型为“ application / javascript” Heroku的文件“ jquery”

Webpacker抛出* Rails 6 *应用程序中manifest.json中找不到的application.css

Rails 5:Sprockets :: FileNotFound-找不到类型为'application / javascript'的文件'jquery-ui / autocomplete'

Webpacker找不到stylesheets / application.css

找不到模块:无法解析“ C:\ Users \ test \ counter-app \ src”中的“ bootstrap / dist / css / bootstrap.css”

具有JavaScript依赖关系的Rails gem

Rails 5:带有 ajax 设置的 Kaminari gem

带有 Shrine Gem 的 Rails 5 pdf 预览

我找不到错误,它显示如下“./src/App.js 语法错误中的错误:意外的令牌 (11:5)”

Rails 5:找不到带有友好 ID 的记录

使用javascript或angularJS在src中显示带有通配符的图像

捆绑程序安装-找不到与gem“ actionpack”兼容的版本-Rails 5

无法使用Devise gem登录Heroku中的Rails 5应用

角5:src / app / app.module.ts(24,24)中的错误:错误TS2307:找不到模块'https'

在ASP.NET 5中找不到CSS文件

带有Rails的GraphQL gem,似乎找不到正确的类型定义?

Rails-找不到类型为'application / javascript'的文件'jquery_ujs'

找不到类型为“ application / javascript”的文件“ rails-ujs”(页面加载时)

错误:在运行Rails 3.2.18的任何存储库中找不到有效的gem'crypt19'(= 1.2.1)

在没有 gem 的情况下使用带有 Rails 5 的 Bootstrap SASS

找不到模块:无法解析“ C:\ react-form-validation-demo \ src”中的“ bootstrap / dist / css / bootstrap-theme.css”

Rails 5,Rspec:在架构中找不到环境数据

Laravel 5找不到css文件

Rails 5,带有Cocoon gem的简单字段用于嵌套资源

如何在Rails应用程序中完全删除对application.js和application.css的所有引用?

Rails 5-simple_form gem中的n + 1查询问题

在./src/.././src/app/app.browser.module.ts中找不到Angular 6 Bootstrap

在Rails应用程序中找不到本地gem类