我试图将我的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;
之前有没有人见过错误?我缺少什么?