问题
我正在使用Semantic UI,开发时应用可以完美地呈现图标字体:
错误详情
在开发环境中,此文件位于:
http://localhost:3000/assets/semantic-ui-css/themes/default/assets/fonts/icons.woff2
在生产环境中,我遇到了以下错误:
planetlauncher.herokuapp.com/:1 GET https://planetlauncher.herokuapp.com/assets/themes/default/assets/fonts/icons.woff planetlauncher.herokuapp.com/:1 GET https://planetlauncher.herokuapp.com/assets/themes/default/assets/fonts/icons.ttf 404 (未找到)
背景
- Webpack与
rails new --webpack:react
命令一起安装。 - Semantic UI通过
yarn add semantic-ui-css
安装。 Application.css
包括:
*= require 'semantic-ui-css/semantic.min.css
assets.rb
包括:
Rails.application.config.assets.paths << Rails.root.join('node_modules')
Rails.application.config.assets.precompile << /\.(?:svg|eot|woff|ttf)$/
此外,由于我的React Webpack依赖关系,我无法预编译资产,必须回退到heroku资产管道。
node_modules
中被 CSS 引用的文件都不会起作用,因为它是通过例如url('asset.css')
而不是asset-url('asset.css')
进行引用的(后者将获取指纹化的 URL)。你找到解决这个问题的方法了吗? - Sam Peacey