代码之家  ›  专栏  ›  技术社区  ›  Simon Cooper

Webpacker 3.5不提供CSS。轨道5.2.2

  •  0
  • Simon Cooper  · 技术社区  · 6 年前

    我有 gem 'webpacker', '~> 3.5' .bin/webpack-dev-server 在一个单独的终端 rails s 我看不出我的衣服有什么样式 /app/CSS/ 文件夹,纯文本打开 localhost:3000 . localhost:3035 只是表演而已 cannot GET/ . 我在应用程序或控制台中没有收到任何错误。是 $.bin/webpack-dev-server 正确的终端命令?

      <%= javascript_pack_tag 'application' %> 
      <%= stylesheet_pack_tag 'application', media: 'all' %>
    

    javascript/包/应用程序.js

    import '../css/simple-grid.css';
    import '../css/application.css'
    

    网页包装.yml

    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:
        - .js
        - .sass
        - .scss
        - .css
        - .module.sass
        - .module.scss
        - .module.css
        - .png
        - .svg
        - .gif
        - .jpeg
        - .jpg
    
    development:
      <<: *default
      compile: true
    
      # Reference: https://webpack.js.org/configuration/dev-server/
      dev_server:
        https: false
        host: localhost
        port: 3035
        public: localhost:3035
        hmr: true
        # Inline should be set to true if using HMR
        inline: true
        overlay: true
        compress: true
        disable_host_check: true
        use_local_ip: false
        quiet: false
        headers:
          'Access-Control-Allow-Origin': '*'
        watch_options:
          ignored: /node_modules/
    
    
    test:
      <<: *default
      compile: true
    
      # Compile test packs to a separate directory
      public_output_path: packs-test
    
    production:
      <<: *default
    
      # Production depends on precompilation of packs prior to booting for performance.
      compile: false
    
      # Cache manifest.json for performance
      cache_manifest: true
    

    包.json

    {
      "name": "GD",
      "private": true,
      "dependencies": {
        "@rails/webpacker": "3.5",
        "autoprefixer": "^9.4.5",
        "axios": "^0.18.0",
        "babel-preset-react": "^6.24.1",
        "prop-types": "^15.6.2",
        "react": "^16.7.0",
        "react-autosize-textarea": "^6.0.0",
        "react-dom": "^16.7.0",
        "react-responsive-navbar": "^1.0.11",
        "react-select": "^2.3.0",
        "webpack-cli": "^3.2.3"
      },
      "devDependencies": {
        "webpack-dev-server": "2.11.2"
      }
    }
    

    控制台中没有错误,这告诉我 webpack Compiled Successfully :

    ^CSimons-MBP-2:GD Simon$ ./bin/webpack-dev-server
    Project is running at http://localhost:3035/
    webpack output is served from /packs/
    Content not from webpack is served from /Users/Simon/Sites/GD/public/packs
    404s will fallback to /index.html
    Hash: 1b5e7c9ec1725de169c0
    Version: webpack 3.12.0
    Time: 2444ms
                                      Asset       Size  Chunks                    Chunk Names
        application-1b5e7c9ec1725de169c0.js     436 kB       0  [emitted]  [big]  application
    application-1b5e7c9ec1725de169c0.js.map     495 kB       0  [emitted]         application
                              manifest.json  142 bytes          [emitted]
       [0] multi (webpack)-dev-server/client?http://localhost:3035 webpack/hot/dev-server ./app/javascript/packs/application.js 52 bytes {0} [built]
    [./app/javascript/css/application.css] ./app/javascript/css/application.css 1.34 kB {0} [built]
    [./app/javascript/css/simple-grid.css] ./app/javascript/css/simple-grid.css 1.34 kB {0} [built]
    [./app/javascript/packs/application.js] ./app/javascript/packs/application.js 538 bytes {0} [built]
    [./node_modules/loglevel/lib/loglevel.js] ./node_modules/loglevel/lib/loglevel.js 7.86 kB {0} [built]
    [./node_modules/strip-ansi/index.js] ./node_modules/strip-ansi/index.js 161 bytes {0} [built]
    [./node_modules/url/url.js] ./node_modules/url/url.js 23.3 kB {0} [built]
    [./node_modules/webpack-dev-server/client/index.js?http://localhost:3035] (webpack)-dev-server/client?http://localhost:3035 7.93 kB {0} [built]
    [./node_modules/webpack-dev-server/client/overlay.js] (webpack)-dev-server/client/overlay.js 3.67 kB {0} [built]
    [./node_modules/webpack-dev-server/client/socket.js] (webpack)-dev-server/client/socket.js 1.08 kB {0} [built]
    [./node_modules/webpack/hot ^\.\/log$] (webpack)/hot nonrecursive ^\.\/log$ 170 bytes {0} [built]
    [./node_modules/webpack/hot/dev-server.js] (webpack)/hot/dev-server.js 1.61 kB {0} [built]
    [./node_modules/webpack/hot/emitter.js] (webpack)/hot/emitter.js 77 bytes {0} [built]
    [./node_modules/webpack/hot/log-apply-result.js] (webpack)/hot/log-apply-result.js 1.31 kB {0} [built]
    [./node_modules/webpack/hot/log.js] (webpack)/hot/log.js 1.04 kB {0} [built]
        + 20 hidden modules
    webpack: Compiled successfully.
    

    0 回复  |  直到 6 年前