难道不能在Rails 4.2的资产管道中添加bower组件css吗

时间:2021-01-20 20:41:31

I'm trying to add bower component (angular ui-grid) to my angularJS + Rails 4.2 application.
The component is working fine in development env, but in production env it works without its css.

我正在尝试在我的angularJS + Rails 4.2应用程序中添加bower组件(角度ui-grid)。该组件在开发环境中运行良好,但在生产环境中,它在没有css的情况下工作。

I've installed the component via a bower to vendor/assets/bower_components and made the following changes in order to integrate it into the assets pipeline:

我已经通过bower安装到供应商/资产/bower_components,并做了以下更改,以便将其集成到资产管道中:

application.css.scss

application.css.scss

@import "angular-ui-grid/ui-grid.css";

application.js

application.js

//= require angular-ui-grid/ui-grid.min.js
//= require_tree .

application.rb

application.rb

config.assets.paths << Rails.root.join('vendor', 'assets', 'bower_components')

assets.rb

assets.rb

Rails.application.config.assets.precompile << %r(.*.(?:eot|svg|ttf|woff)$)
Rails.application.config.assets.precompile += %w( ui-grid.css )

I executed rake assets:precompile which generated the following output:

我执行了rake asset:precompile,生成如下输出:

Writing /source/myapp/public/assets/application-546acf8e965ef660d80be61d1314dcef.js
Writing /source/myapp/public/assets/application-bf4c9902bcb508f0250e847dc63c3321.css
Writing /source/myapp/public/assets/angular-ui-grid/ui-grid-70f73890ff81d1e19e758473a9ff1f1e.eot
Writing /source/myapp/public/assets/angular-ui-grid/ui-grid-069439f9e57a19c07fad6095a9056446.svg
Writing /source/myapp/public/assets/angular-ui-grid/ui-grid-f681537c8135d9deb670ceadfb8eddd4.ttf
Writing /source/myapp/public/assets/angular-ui-grid/ui-grid-a3319d6298bca8dd2bcaae48735afe00.woff
Writing /source/myapp/public/assets/bootstrap-sass-official/assets/fonts/bootstrap/glyphicons-halflings-regular-e4c812e8c30abb98e787ab176cb74129.eot
Writing /source/myapp/public/assets/bootstrap-sass-official/assets/fonts/bootstrap/glyphicons-halflings-regular-c9450138a7b29547267148145ba65c3e.svg
Writing /source/myapp/public/assets/bootstrap-sass-official/assets/fonts/bootstrap/glyphicons-halflings-regular-7ef334f0e220af09b5aa3a8283ccaa6a.ttf
Writing /source/myapp/public/assets/bootstrap-sass-official/assets/fonts/bootstrap/glyphicons-halflings-regular-97811df08b2f65e376ad5b37fc5f315b.woff

For some reason the ../assets/angular-ui-grid/ui-grid.css is missing from the precompile output!

由于某种原因。/资产/angular-ui-grid/ui-grid。在预编译输出中缺少css !

When I run my Rails app in production env (in development it works fine), the ui-grid component is running (=> the ui-grid javascript was integrated successfully into the assets pipeline), but without its css (all ui-grid.css classes), and it looks horrible.

当我在production env中运行Rails应用程序(在开发中运行良好)时,ui-grid组件正在运行(=> ui-grid javascript已经成功地集成到资产管道中),但是没有css(所有ui-grid)。它看起来很可怕。

How do I add the ui-grid.css into the assets pipeline?

如何添加ui网格。css进入资产管道?

1 个解决方案

#1


2  

I ran into the same issue. In addition to doing a sass import, you also need to do a sprockets import.

我遇到了同样的问题。除了进行sass导入之外,还需要导入链轮。

add

添加

*= require angular-ui-grid/ui-grid.css

* =需要angular-ui-grid / ui-grid.css

To the manifest, and you should be fine.

到舱单上,你会没事的。

#1


2  

I ran into the same issue. In addition to doing a sass import, you also need to do a sprockets import.

我遇到了同样的问题。除了进行sass导入之外,还需要导入链轮。

add

添加

*= require angular-ui-grid/ui-grid.css

* =需要angular-ui-grid / ui-grid.css

To the manifest, and you should be fine.

到舱单上,你会没事的。