asset-pipeline - Rails 5.1 将 js 文件从 app/assets/javascripts 移动到 app/javascripts
问题描述
我试图将我的 JS 文件app/assets/javascripts
从app/javascript
. 基本上从 Asset Pipeline 转移到 Webpack。
我在这个过程中遇到了多个错误。
1.我唯一做的就是移动文件并从中删除预编译语句config/initializers/assets.rb
这就是我得到的:
DEPRECATION WARNING: The asset "disallow-char.js" is not present in the asset pipeline.Falling back to an asset that may be in the public folder.
This behavior is deprecated and will be removed.
To bypass the asset pipeline and preserve this behavior,
use the `skip_pipeline: true` option.
2.然后我在文件上添加了以下内容html.haml
:
```= javascript_include_tag 'disallow-char.js', skip_pipeline: true```
这就是我得到的:
Started GET "/javascripts/disallow-char.js" for ::1 at 2018-04-26 15:11:18 -0500
Processing by ErrorsController#routing as JS
Parameters: {"any_bad_route"=>"javascripts/disallow-char"}
::1 - - [26/Apr/2018:15:11:18 CDT] "GET /packs/application-26fc747cc9104717d89e.js HTTP/1.1" 304 0
在浏览器上,我收到此错误:
GET http://localhost:3000/javascripts/disallow-char.js net::ERR_ABORTED
该文件的位置是app/javascripts/frontend/disallow-char.js
我的app/javascript/packs/application.js
样子如下:
/* eslint no-console:0 */
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.
//
// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
// layout file, like app/views/layouts/application.html.erb
const frontend = require.context('../frontend', true, /\.js$/);
application.load(definitionsFromContext(frontend));
export default application;
有没有人见过那里的错误?有什么我想念的吗?
解决方案
推荐阅读
- java - 春季启动时请求正文为空
- javascript - 如何从 html 按钮单击执行 JavaScript?
- kubernetes - 从特定 IP 地址出口 kubernetes 服务/pod
- javascript - 我如何解析下一个字符串:
- android - 如何在 gradle 中启用视图绑定?
- apache-spark - Spark Shuffle 写入大小是输入大小的 7500 倍
- javascript - 无法访问模块函数中的 quill 实例
- postgresql - 与触发函数和插入语句sql有关的错误
- python - Python中的多个窗口,tkinter
- 3d - 使用 Python 创建 3D EEG 地形图