Javascript/Webpack Rails 6. application.js 语法中的流水线。将 js 文件放入 javascript/packs 文件夹
Javascript/Webpack pipelining in Rails 6. application.js syntax. putting js files in javascript/packs folder
我有一个 bootstrap 模板用于 rails 项目。在 rails 6 之前,将模板与项目集成很容易。现在 rails 包含 6 个 webpack。现在我无法将文件复制到 javascript/packs 文件夹并通过 application.js 调用这些 .js 文件。编译 webpack 时,显示:
ERROR in ./app/javascript/packs/application.js Module not found:
Error: Can't resolve 'plugins/jquery/jquery.min' in
'app/javascript/packs'
@ ./app/javascript/packs/application.js 25:0-36 <= this error
我在 app/javascript
文件夹中创建了 src 文件夹,并将所有 .js
文件粘贴到其中。 application.js
也是由 require('src/file_name')
完成的,然后我将 webpacker.yml
resolved_paths
更改为 resolved_paths: ['app/javascript/src']
。现在一切正常。
我有一个 bootstrap 模板用于 rails 项目。在 rails 6 之前,将模板与项目集成很容易。现在 rails 包含 6 个 webpack。现在我无法将文件复制到 javascript/packs 文件夹并通过 application.js 调用这些 .js 文件。编译 webpack 时,显示:
ERROR in ./app/javascript/packs/application.js Module not found: Error: Can't resolve 'plugins/jquery/jquery.min' in 'app/javascript/packs' @ ./app/javascript/packs/application.js 25:0-36 <= this error
我在 app/javascript
文件夹中创建了 src 文件夹,并将所有 .js
文件粘贴到其中。 application.js
也是由 require('src/file_name')
完成的,然后我将 webpacker.yml
resolved_paths
更改为 resolved_paths: ['app/javascript/src']
。现在一切正常。