2017-09-01 22 views
7

webpackerを使用して新しいrails 5.1アプリケーションでページを読み込もうとすると、このエラーが発生します。 webpackerにもCSSを扱いたいと思います。stylesheet_pack_tag webpacker gemを含むrails 5.1のapp/javascript/src/application.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' 

私はrails serverと一緒./bin/webpack-dev-serverを実行しています。 bundle bundle exec rails webpacker:install:react

rails new myapp --webpack 私は、単一のCSSファイルapp/javascript/src/application.cssを持っている:私は使ってアプリを作成しました。 (何かが間違っていると感じるように書く)

ただ一つのルートが定義されている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 

です彼らはもっと親切にして助けてください。何か他に頼むと私の質問に追加します。ありがとう!

答えて

2

application.js内:

import "path to application.css" 
関連する問題