无法使用 webpacker 为 cookieconsent 加载 css 个文件
Unable to load css files for cookieconsent with webpacker
我正在 rails 5.1.4.
上的 ruby 中尝试将 cookieconsent 软件包与 webpacker 一起使用
我的 package.json 是
{
"dependencies": {
"@rails/webpacker": "3.5",
"bootstrap": "^4.1.1",
"cookieconsent": "^3.0.6"
},
"devDependencies": {
"webpack-dev-server": "2.11.2"
我在app/javascript中添加了一个cookieconsent.scss,内容如下
@import 'cookieconsent/build/cookieconsent.min.css'
我是运行 webpack-dev-server 编译成功,包括处理cookieconsent.scss文件即
Child extract-text-webpack-plugin node_modules/extract-text-webpack-plugin/dist node_modules/css-loader/index.js??ref--2-2!node_modules/postcss-loader/lib/index.js??ref--2-3!node_modules/sass-loader/lib/loader.js??ref--2-4!app/javascript/cookieconsent.scss:
[0] ./node_modules/css-loader??ref--2-2!./node_modules/postcss-loader/lib??ref--2-3!./node_modules/sass-loader/lib/loader.js??ref--2-4!./app/javascript/cookieconsent.scss 10.7 kB {0} [built]
[1] ./node_modules/css-loader/lib/css-base.js 2.26 kB {0} [built]
在正在加载的 html 页面的头部我有
<%= stylesheet_pack_tag 'cookieconsent' %>
当我加载页面时,我在 stylesheet_pack_tag 行
收到以下错误消息
Webpacker::Manifest::MissingEntryError - Webpacker can't find cookieconsent.css in /Users/Chris/Sites/golf_mentor/public/packs/manifest.json. Possible causes:
1. You want to set webpacker.yml value of compile to true for your environment
unless you are using the `webpack -w` or the webpack-dev-server.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your webpack configuration is not creating a manifest.
Your manifest contains:
{
"application.css": "/packs/application-4aa426d9718df1187dbf816f0f19f567.css",
"application.css.map": "/packs/application-4aa426d9718df1187dbf816f0f19f567.css.map",
"application.js": "/packs/application-157f642ed5e88a31abbb.js",
"application.js.map": "/packs/application-157f642ed5e88a31abbb.js.map",
"counter.js": "/packs/counter-9d94c8ee2c39e62e654d.js",
"counter.js.map": "/packs/counter-9d94c8ee2c39e62e654d.js.map"
}
:
app/views/pages/temp.html.erb:3:in `block in _app_views_pages_temp_html_erb__4517159242875817520_70136616900600'
app/views/pages/temp.html.erb:1:in `_app_views_pages_temp_html_erb__4517159242875817520_70136616900600'
我该如何解决这个问题?
我最终通过使用链轮安装 cookieconsent 解决了这个问题。
然而,这个 post、https://rubyyagi.com/how-to-use-bootstrap-and-jquery-in-rails-6-with-webpacker/ 虽然没有专门处理 cookieconsent,但确实提供了有关如何使用 webpacker 安装第三方 css 文件的更多信息。
我正在 rails 5.1.4.
上的 ruby 中尝试将 cookieconsent 软件包与 webpacker 一起使用我的 package.json 是
{
"dependencies": {
"@rails/webpacker": "3.5",
"bootstrap": "^4.1.1",
"cookieconsent": "^3.0.6"
},
"devDependencies": {
"webpack-dev-server": "2.11.2"
我在app/javascript中添加了一个cookieconsent.scss,内容如下
@import 'cookieconsent/build/cookieconsent.min.css'
我是运行 webpack-dev-server 编译成功,包括处理cookieconsent.scss文件即
Child extract-text-webpack-plugin node_modules/extract-text-webpack-plugin/dist node_modules/css-loader/index.js??ref--2-2!node_modules/postcss-loader/lib/index.js??ref--2-3!node_modules/sass-loader/lib/loader.js??ref--2-4!app/javascript/cookieconsent.scss:
[0] ./node_modules/css-loader??ref--2-2!./node_modules/postcss-loader/lib??ref--2-3!./node_modules/sass-loader/lib/loader.js??ref--2-4!./app/javascript/cookieconsent.scss 10.7 kB {0} [built]
[1] ./node_modules/css-loader/lib/css-base.js 2.26 kB {0} [built]
在正在加载的 html 页面的头部我有
<%= stylesheet_pack_tag 'cookieconsent' %>
当我加载页面时,我在 stylesheet_pack_tag 行
收到以下错误消息Webpacker::Manifest::MissingEntryError - Webpacker can't find cookieconsent.css in /Users/Chris/Sites/golf_mentor/public/packs/manifest.json. Possible causes:
1. You want to set webpacker.yml value of compile to true for your environment
unless you are using the `webpack -w` or the webpack-dev-server.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your webpack configuration is not creating a manifest.
Your manifest contains:
{
"application.css": "/packs/application-4aa426d9718df1187dbf816f0f19f567.css",
"application.css.map": "/packs/application-4aa426d9718df1187dbf816f0f19f567.css.map",
"application.js": "/packs/application-157f642ed5e88a31abbb.js",
"application.js.map": "/packs/application-157f642ed5e88a31abbb.js.map",
"counter.js": "/packs/counter-9d94c8ee2c39e62e654d.js",
"counter.js.map": "/packs/counter-9d94c8ee2c39e62e654d.js.map"
}
:
app/views/pages/temp.html.erb:3:in `block in _app_views_pages_temp_html_erb__4517159242875817520_70136616900600'
app/views/pages/temp.html.erb:1:in `_app_views_pages_temp_html_erb__4517159242875817520_70136616900600'
我该如何解决这个问题?
我最终通过使用链轮安装 cookieconsent 解决了这个问题。
然而,这个 post、https://rubyyagi.com/how-to-use-bootstrap-and-jquery-in-rails-6-with-webpacker/ 虽然没有专门处理 cookieconsent,但确实提供了有关如何使用 webpacker 安装第三方 css 文件的更多信息。